OpenAPITools / openapi-generator-bazel

Bazel plugin for OpenAPI Generator
Apache License 2.0
66 stars 48 forks source link

Can't do gofmt #19

Open cvigo opened 3 years ago

cvigo commented 3 years ago

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, tryexport GO_POST_PROCESS_FILE="/usr/local/bin/gofmt -w"(Linux/Mac)

wing328 commented 3 years ago

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

cvigo commented 3 years ago

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

Didn't work either...

wing328 commented 3 years ago

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

rahul-roy-glean commented 1 week ago

@cvigo i know it's been a while , but were you able to get this to work ?