Skip to content

Commit

Permalink
feat: support go.mod replace
Browse files Browse the repository at this point in the history
  • Loading branch information
franklinkim committed Apr 15, 2021
1 parent b726d97 commit 0f6f97c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions gotsrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"net/http"
"os"
"path"
"path/filepath"
"sort"
"strings"
"time"
Expand Down Expand Up @@ -120,6 +121,17 @@ func parseDir(goPaths []string, gomod config.Namespace, packageName string) (map
break
}
}
for _, rep := range gomod.ModFile.Replace {
if strings.HasPrefix(packageName, rep.Old.String()) {
if strings.HasPrefix(rep.New.String(), ".") || strings.HasPrefix(rep.New.String(), "/") {
dir := strings.Replace(packageName, rep.Old.String(), filepath.Join(gomod.Path, rep.New.String()), 1)
return parser.ParseDir(fset, dir, parserExcludeFiles, parser.AllErrors)
} else {
packageName = rep.New.String()
break
}
}
}
dir = path.Join(goPath, "pkg", "mod", packageName)
} else if strings.HasSuffix(goPath, "vendor") {
dir = path.Join(goPath, packageName)
Expand Down

0 comments on commit 0f6f97c

Please sign in to comment.