From 6aca89fe8471d7b06662386451af8eb5661c9cdd Mon Sep 17 00:00:00 2001 From: kun Date: Tue, 4 Sep 2018 10:35:50 +0800 Subject: [PATCH] support multiple GOPATH --- main.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index ece1cb5..7f74ec4 100644 --- a/main.go +++ b/main.go @@ -22,11 +22,12 @@ func init() { } func main() { - gp := os.Getenv("GOPATH") - if gp == "" { + gpEnv := os.Getenv("GOPATH") + if gpEnv == "" { panic("can not find $GOPATH") } - cacheDir = filepath.Join(gp, "pkg", "mod", "cache", "download") + gp := filepath.SplitList(gpEnv) + cacheDir = filepath.Join(gp[0], "pkg", "mod", "cache", "download") http.Handle("/", mainHandler(http.FileServer(http.Dir(cacheDir)))) err := http.ListenAndServe(listen, nil) if nil != err {