Hi all,

I think I already know the answer, but hoping there is a way I am missing to 
get gofmt to stop generating the "import in a program, not an importable 
package" error when parsing a `tools.go` file with the `tools` build tag.

If you are not familiar, there is an approach several people have written about 
to store references to your project's required Go-based CLI tools in a 
`tools.go` file:

https://play-with-go.dev/tools-as-dependencies_go119_en/
https://www.jvt.me/posts/2022/06/15/go-tools-dependency-management/

I am using it because oapi-codegen recommends it for maintaining enabling 
others who may clone your repo to easily get the proper tools then need 
installed:

https://github.com/oapi-codegen/oapi-codegen/?tab=readme-ov-file#install

And grpc-gateway evidently recommends it too:

https://github.com/grpc-ecosystem/grpc-gateway#installation 

When I run gofmt — which GoLand does prior to a commit — it generates that as 
an error.  People have said just to ignore it:

https://github.com/grpc-ecosystem/grpc-gateway/issues/3515
https://stackoverflow.com/questions/77664121/import-is-a-program-not-an-importable-package

However — call me anal —I really want to ensure no errors are generated unless 
they are errors I really need to fix. Otherwise I will likely get complacent 
and accidentally commit a real error.

Is there any way to get gofmt to ignore code based on build tags, e.g. `tools` 
in this case?

-Mike

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/31160B8D-8DBC-43C7-8396-F74B2B8AFD92%40newclarity.net.

Reply via email to