Skip to content

Commit

Permalink
Add support for Go modules based on dvyukov#195 (comment)
Browse files Browse the repository at this point in the history
  • Loading branch information
disconnect3d committed Sep 18, 2019
1 parent 1810d38 commit 3e135c6
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions go-fuzz-build/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ func makeTags() string {
// that clients can then modify and use for calls to go/packages.
func basePackagesConfig() *packages.Config {
cfg := new(packages.Config)
cfg.Env = append(os.Environ(), "GO111MODULE=off")
return cfg
}

Expand Down Expand Up @@ -235,7 +234,7 @@ func (c *Context) loadPkg(pkg string) {
// See https://golang.org/issue/30826 and https://golang.org/issue/30828.
rescfg := basePackagesConfig()
rescfg.Mode = packages.NeedName
rescfg.BuildFlags = []string{"-tags", makeTags()}
rescfg.BuildFlags = []string{"-mod=vendor", "-tags", makeTags()}
respkgs, err := packages.Load(rescfg, pkg)
if err != nil {
c.failf("could not resolve package %q: %v", pkg, err)
Expand All @@ -255,7 +254,7 @@ func (c *Context) loadPkg(pkg string) {
// of invalid code than trying to compile instrumented code.
cfg := basePackagesConfig()
cfg.Mode = packages.LoadAllSyntax
cfg.BuildFlags = []string{"-tags", makeTags()}
cfg.BuildFlags = []string{"-mod=vendor", "-tags", makeTags()}
// use custom ParseFile in order to get comments
cfg.ParseFile = func(fset *token.FileSet, filename string, src []byte) (*ast.File, error) {
return parser.ParseFile(fset, filename, src, parser.ParseComments)
Expand Down

0 comments on commit 3e135c6

Please sign in to comment.