Live data from Hacker News

How to start a Go project in 2023

boyter.org

11–20 of 205 posts

Re: How to start a Go project in 2023

#13
post #9

I'd add "What's the best web framework?" and answer it with "No." (Go comes batteries included)

That’s quite true, although for routing / muxing I do tend to use a third party one. The numerous Go web frameworks are solely created for the glory of the authors.

Re: How to start a Go project in 2023

#14
post #5

well written post! one minor thing: I've skipped using build tags for integration tests because those tests will be out of sync one day with your main code, even with Goland (?). Instead I use the usual test and check if an environment variable is set, if not, then t.Skipf("env var %q not set, skipping integration test",envVarName) or you can use an additional CLI flag, e.g. in `feature_test.go` write func init() { f…

I usually make use of the long and short testmodes that are supported https://stackoverflow.com/questions/55180613/how-do-i-write-...

I used to use buildflags before this, but my linter ignored those files so they were hard to maintain

Re: How to start a Go project in 2023

#15
I see the note in the article around using -ldflags="-s -w" - is there any other useful tool for binary size analysis/reduction? I was surprised when my binary size doubled when incorporating the K8s client package to get a secret; just using the HTTP secrets API manually without referencing the client package shrank the size by many MB. It would be nice to find similar opportunities for size reduction that aren’t as obvious.

Re: How to start a Go project in 2023

#16
Looks like a good resource for go beginners.

Would there something similar for a next, second, step that focuses on go concurrency aspects?

Go (and erlang/elixir) as touted as concurrency-ready platforms and good overviews of setups, tools and best practices might help more people benefit.

Re: How to start a Go project in 2023

#17
How to start a new Go project:

  go mod init mymodule
Go's default toolchain is fine, everything else is optional. Some questionable advice in the article:

- Vendoring dependencies using "go mod vendor" is not a good default workflow - it bloats the repo, the checked in code is impossible to review, and is generally a pain to keep up to date. Don't, unless you really have to.

- There's no point in stripping a binary or even using UPX on it unless you're targeting extremely low memory environments (in which case Go is the wrong tool anyways), all it'll do it make it harder to debug.

Re: How to start a Go project in 2023

#18

Things I can't live without in a new Go project in no particular order: - https://github.com/golangci/golangci-lint - meta-linter - https://goreleaser.com - automate release workflows - https://magefile.org - build tool that can version your tools - https://godoc.org/github.com/ory/dockertest/v3 - run containers for e2e testing - https://github.com/ecordell/optgen - generate functional options - https://golang.org/x/…

You’ve gotta check out Charm’s tools for CLI/TUI dev. They are doing some great work.

https://charm.sh/

Re: How to start a Go project in 2023

#20
post #9

I'd add "What's the best web framework?" and answer it with "No." (Go comes batteries included)

A better answer would be some recommendations for component pieces. e.g., I will need most of the essential things in https://github.com/go-chi/chi, so why bother rolling a version myself? The same goes for things like sqlx. I'm averse to leaning on a "framework," but do find good value in targeted libraries.
Post reply on HN