Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

Commit

Permalink
dep: remove usage of filepath.FromSlash & filepath.ToSlash
Browse files Browse the repository at this point in the history
Remove the usage of filepath.FromSlash and filepath.ToSlash in GOPATH
detection functions *Ctx.SetPaths and *Ctx.detectGOPATH.

This should ensure the GOPATH returned from *Ctx.DetectProjectGOPATH
uses the filesystem separator instead of slashes.

Signed-off-by: Ibrahim AshShohail <[email protected]>
  • Loading branch information
ibrasho committed Jun 21, 2017
1 parent c79b048 commit 6e2930f
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@ func (c *Ctx) SetPaths(wd string, GOPATHs ...string) error {
if len(GOPATHs) == 0 {
GOPATHs = getGOPATHs(os.Environ())
}
for _, gp := range GOPATHs {
c.GOPATHs = append(c.GOPATHs, filepath.ToSlash(gp))
}

c.GOPATHs = append(c.GOPATHs, GOPATHs...)

return nil
}
Expand Down Expand Up @@ -230,7 +229,7 @@ func (c *Ctx) DetectProjectGOPATH(p *Project) (string, error) {
// detectGOPATH detects the GOPATH for a given path from ctx.GOPATHs.
func (c *Ctx) detectGOPATH(path string) (string, error) {
for _, gp := range c.GOPATHs {
if fs.HasFilepathPrefix(filepath.FromSlash(path), gp) {
if fs.HasFilepathPrefix(path, gp) {
return gp, nil
}
}
Expand Down

0 comments on commit 6e2930f

Please sign in to comment.