Get Actual Import Path from go/cmd or go/build

Is there a way to get proper import path when using go/ packages to generate custom Go documentation?

as in:

import example.com/group/repo

over

import .

I tried doc.ImportPath and build.ImportPath from both go/doc and go/build respectively. They always return the relative path . when the input path is the same relative path.

I’m looking at removing the custom functions to read go.mod for the import path construction here:

Any idea would be appreciated. Thanks in adv!

1 Like

Unfortunately, I don’t have the answer. I haven’t yet implemented any go generate packages, but I’m interested in doing so and I imagine knowing this information would be helpful. I’ve bookmarked this post to see if anyone else comes up with the answer. Good luck!

Thanks. I will role with the temporary workaround for the time being. The current documentations are scarce when it is related to internal sections of the Go Modules and docs.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.