I am trying to create an auto-generated file "txstatus_string.go" within Bazel sandbox which relies on a go file and it is getting created with below stringer command:
go:generate stringer -type TxStatus
I am using a bazel genrule like this:
genrule(
name = "gen-txstatus-stringer",
srcs = [
"schemachange.go",
],
outs = ["txstatus_string.go"],
cmd = """
GO_REL_PATH=`dirname $(location @go_sdk//:bin/go)`
GO_ABS_PATH=`cd $$GO_REL_PATH && pwd`
env PATH=$$GO_ABS_PATH HOME=$(GENDIR) \
$(location @org_golang_x_tools//cmd/stringer:stringer) -output=$@ \
-type=TxStatus $(location schemachange.go)
""",
tools = [
"@go_sdk//:bin/go",
"@org_golang_x_tools//cmd/stringer",
],
)
But not sure why in this case stringer is failing due to "stringer: can't happen: constant is not an integer" Any one has a better idea on how to approach or why this is happening?
I already created some other stringer files using a common stringer
genrule and everything goes well.
If you want to go deeper in code this is an opensource Github repo, that you can go and check =)