bazelbuild / rules_go

Go rules for Bazel
Apache License 2.0
1.37k stars 651 forks source link

Hello World for Golang is a bit difficult. #3925

Open PaulRashidi opened 5 months ago

PaulRashidi commented 5 months ago

What version of rules_go are you using?

0.46.0

What version of gazelle are you using?

I'm not quite sure what gazelle is TBH, but it seems to be automatically pulled in via the MODULE.bazel file's ability to get dependencies from Bazel Central so the rules_go dependency above would tell you which bazel_gazelle version I use since I have no other dependencies.

What version of Bazel are you using?

7.1.1

Does this issue reproduce with the latest releases of all the above?

Yes, I'm using the latest versions.

What operating system and processor architecture are you using?

Darwin amd64

Any other potentially useful information about your toolchain?

N/A

What did you do?

I'm just trying to set up a Hello World Golang project with Bazel and I've got it working, but I don't know if there is a clear example available that's up to date. I wanted to highlight this since I think Go + Bazel is a pretty good combination.

What did you expect to see?

I expected to see the https://github.com/bazelbuild/examples to have an example that shows how to use rules_go easily. I expected most examples on https://github.com/bazelbuild/examples to use MODULE.bazel rather than WORKSPACE since MODULE.bazel has been around a long time.

What did you see instead?

I had to do a bit of stumbling to navigate set up with WORKSPACE, old plugin versions using various incomplete blog posts. The most useful was https://medium.com/@patrickkoss/bazel-in-action-a-journey-through-efficient-builds-in-go-a0be96978cfb but with it missing most of the content of the files it wasn't complete. I'm a Googler, so I had similar knowledge to pull from and without that it would have take quite a bit longer to navigate this. After having seen how easy it is to set up I'm surprised there isn't a single project example for Go like there are for CPP, but even the CPP ones could be converted to MODULE.bazel