From 712090b747799107b9571aa3be97ee3372b9c6ba Mon Sep 17 00:00:00 2001 From: mlange-42 Date: Thu, 2 Feb 2023 15:29:29 +0100 Subject: [PATCH] replace deprecated package compilation mode, add NeedsDeps --- gen.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gen.go b/gen.go index 377f619..549ee2a 100644 --- a/gen.go +++ b/gen.go @@ -98,7 +98,7 @@ func loadPackage(path string, buildFirst bool, buildTags string) (*packages.Pack args = append(args, "-tags", buildTagStr) } args = append(args, "-v", path) - fmt.Printf("go %v\n", strings.Join(args, " ")) + fmt.Printf("go %s\n", strings.Join(args, " ")) cmd := exec.Command("go", args...) cmd.Stdin = os.Stdin cmd.Stdout = os.Stdout @@ -115,7 +115,8 @@ func loadPackage(path string, buildFirst bool, buildTags string) (*packages.Pack } // golang.org/x/tools/go/packages supports modules or GOPATH etc - bpkgs, err := packages.Load(&packages.Config{Mode: packages.LoadTypes}, path) + mode := packages.NeedName | packages.NeedFiles | packages.NeedCompiledGoFiles | packages.NeedDeps | packages.NeedImports | packages.NeedTypes | packages.NeedTypesSizes + bpkgs, err := packages.Load(&packages.Config{Mode: mode}, path) if err != nil { log.Printf("error resolving import path [%s]: %v\n", path,