go generate on build stage

2.1k views Asked by At

In some build systems like gradle or blaze I can generate code (ent or proto) on a build stage and don't add in to a repository.

Is it possible to do the same for the go build command?

1

There are 1 answers

2
Alexus1024 On

Yes, if you add "go generate" as your pre-build step in CI script.

$ go generate
$ go build
$ go test

But I would recommend more practical approach: to store your generated code in your repo and check it on CI - run go generate and assert that there is no changes.

Links