We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v0.1.11
//go:build darwin && !linux && !freebsd && !netbsd && !openbsd && !windows && !js // +build darwin,!linux,!freebsd,!netbsd,!openbsd,!windows,!js package mypackage //go:generate stringer -type=MyEnum type MyEnum uint32 const ( DarwinValue1Enum MyEnum = iota DarwinValue2Enum )
stringer -type=MyEnum
myenum_string.go
I expect to get a valid code for all platform. Which here means the MyEnum.String() should only exists on darwin platform.
MyEnum.String()
The new generated file is only valid when compiling for darwin, and not for other GOOS: GOOS=linux go vet ./...
darwin
GOOS
GOOS=linux go vet ./...
./myenum_string.go:11:8: undefined: DarwinValue1Enum ./myenum_string.go:12:8: undefined: DarwinValue2Enum ./myenum_string.go:19:9: undefined: MyEnum ./myenum_string.go:20:10: undefined: MyEnum
I suggest to either:
stringer
//go:build
--platform
--template
The text was updated successfully, but these errors were encountered:
Note: I looked for this kind of issue, but I may missed it. If so, I am sorry for the duplication;;;
Sorry, something went wrong.
Duplicate of #47179
No branches or pull requests
stringer version
What did you do?
stringer -type=MyEnum
to generate a new filemyenum_string.go
: https://go.dev/play/p/eR6E7A9A7aUWhat did you expect to see?
I expect to get a valid code for all platform. Which here means the
MyEnum.String()
should only exists on darwin platform.What did you see instead?
The new generated file is only valid when compiling for
darwin
, and not for otherGOOS
:GOOS=linux go vet ./...
Suggestions
I suggest to either:
stringer
copies the header from the current file so it inject automatically the right//go:build
comments.--platform
flag as a list of string sostringer
automatically adds the header.--template
flag as a path to a template, sostringer
use it to generate go files (and I can add my own//go:build
comment).The text was updated successfully, but these errors were encountered: