How to start a Go project in 2023
I would like to mention Magefile. We recently have been using it over makefiles and it has been amazing. Removes more non-go dependencies. You write your files in Go, and it all works really well.
Between that, goreleaser, 2-stage dockerfiles, static binaries, etc. It all just works so well and only needs Go for most things.
Recently for actual stuff we have been using Exho, Zerolog, and fairly common libraries for most tools.
If your code uses goroutines i recommend https://github.com/uber-go/goleak to detect leaks
And then for GUID generation we use https://github.com/oklog/ulid instead of https://github.com/google/uuid/
Does Go allow to load an in-process profiler like the CLR (dotnet)? It’s very useful for application monitoring, e.g NewRelic, DataDog.
Integration tests via build tags: no! Don't do this! It'll mean you don't get build failures if you break them.
Make a little test utils folder, and `t.Skip("disabled, use ENV_VAR to enable")` in integration tests. Then they're always built, always linted, always work in IDEs, you are told they exist, and told how to enable them. None of that is true with build tags.
Cool to see that people still find "50 Shades of Go" useful :) If anybody has additional gotchas you want to share I'd love to add them!
This is how I start a Go project in 2023.
I try to stick to the stdlib as much as possible, which goes surprisingly far.
mkdir new-repo vim new-repo/main.go
I'm learning Go right now and these comments are really precious, so many useful respurces