Skip to content
New issue

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

Can't do gofmt #19

Open
cvigo opened this issue Mar 26, 2021 · 3 comments
Open

Can't do gofmt #19

cvigo opened this issue Mar 26, 2021 · 3 comments

Comments

@cvigo
Copy link

cvigo commented Mar 26, 2021

If you want the generated source files to be go-formatted, you must set the environment variable GO_POST_PROCESS_FILE="/usr/local/bin/gofmt -w"

I tried

  1. bazel build [...] --host_action_env=GO_POST_PROCESS_FILE="/usr/local/bin/gofmt -w"
  2. bazel build [...] --action_env=GO_POST_PROCESS_FILE="/usr/local/bin/gofmt -w"
  3. GO_POST_PROCESS_FILE="/usr/local/bin/gofmt -w" bazel build [...]

None of them works... I forked the repo to remove the 1>/dev/null redirection so I can see the generator output, and got this:

[main] INFO o.o.c.languages.AbstractGoCodegen - Environment variable GO_POST_PROCESS_FILE not defined so Go code may not be properly formatted. To define it, try export GO_POST_PROCESS_FILE="/usr/local/bin/gofmt -w" (Linux/Mac)

@wing328
Copy link
Member

wing328 commented Apr 30, 2021

What about setting the environment variable via export before running bazel build ?

@cvigo
Copy link
Author

cvigo commented Apr 30, 2021

What about setting the environment variable via export before running bazel build ?

Didn't work either...

@wing328
Copy link
Member

wing328 commented Apr 30, 2021

As a workaround, run gofmt on the output folder after the code generation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants