//go:generate stringer -type=Suit
// Suit represents card's category.
type Suit uint8
Spade Suit = iota
This, when issuing
go generate, should generate some file. Instead, But I am getting this:
$ go generate
stringer: no value for constant Spade
main.go:1: running "stringer": exit status 1
Perhaps something in changed in stringer package?
I just copied your code to my clipboard and ran the following commands:
go get golang.org/x/tools/cmd/stringer
cat > ./deck.go
# middle click to paste, then Ctrl+D
And did not get that error.
deck.Suit.String was generated correctly. Can you try removing your
golang.org/x/tools/cmd/stringer package and re-
go get it and try again?
Oh, it worked after removing and go getting again.
Not sure what made it fail before.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.