github.com/benma/gogen@v0.0.0-20160826115606-cf49914b915a/gogenutil/remove_gopath.go (about) 1 package gogenutil 2 3 import ( 4 "os" 5 "path" 6 "strings" 7 ) 8 9 // StripGopath teks the directory to a package and remove the gopath to get the 10 // cannonical package name 11 func StripGopath(p string) string { 12 for _, gopath := range strings.Split(os.Getenv("GOPATH"), ":") { 13 p = strings.Replace(p, path.Join(gopath, "src")+"/", "", 1) 14 } 15 return p 16 }