Paul & Ian. `tools/go/packages <https://godoc.org/golang.org/x/tools/go/packages>` worked great in my case. thanks.
On Wednesday, November 7, 2018 at 12:05:04 AM UTC-5, Paul Jolly wrote: > > cc golang-tools > > You need to be using https://godoc.org/golang.org/x/tools/go/packages in > place of go/build. It handles everything from import finding to type > checking. > > Any further questions/problems please ask > > On Wed, 7 Nov 2018, 04:35 bsr <bsr...@gmail.com <javascript:> wrote: > >> How can I find the path (directory) of a package which uses go module >> (1.11). >> >> I had code (for go:generate) which uses package name to locate source >> code relative to GOPATH and import using >> https://golang.org/pkg/go/build/#Import >> >> Now, once I started using module, the package name is prefixed with >> module name and even if I strip the module name, `build.Import` only look >> at GOROOT, and since no GOPATH is set, it won't search in the current >> package directory. using `os.Getwd` is not reliable as the source code is >> nested at different levels and can't reliably find the source. >> >> So, what is the best way to locate source (or the path ) based on package >> name of a go module enabled project. >> >> Any pointers greatly appreciated. >> thanks. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "golang-nuts" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to golang-nuts...@googlegroups.com <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.