More robust GOPATH substitution
in header comments of generated files.
@@ -158,8 +158,12 @@ func (g *Generator) Run() ([]string, error) {
}
for i, a := range os.Args[1:] {
for _, p := range gopaths {
- if strings.Contains(a, p) {
- args[i] = strings.Replace(a, p, "$(GOPATH)", -1)
+ if strings.HasPrefix(a, p) {
+ suf := "$(GOPATH)"
+ if !strings.HasSuffix(p, string(filepath.Separator)) {
+ suf += string(filepath.Separator)
+ }
+ args[i] = strings.Replace(a, p, suf, 1)
break
}
}
