Why can't the stringer find the package?

Any idea how I can fix the error below? I have a go (stringer) generator that I am trying to run, but it continues to report that it cannot find the package import, although the package is definitely imported.

stringer: checking package: main.go:13:3: could not import example.io/api/util (can't find import: example.io/api/util)
main.go:33: running "stringer": exit status 1
+4
source share
1 answer

From this thread :

This seems to be stupid: 4-part imports are usually subpackages, and they must be “ installed ” before you can use them. I did the following on the command line to solve my problem:

So first try:

go install <yourpackage>

The announcement shows whether after that the generation will work.

1.4.2 :

go get -u golang.org/x/tools/cmd/stringer
+5

All Articles