Live data from Hacker News

How to start a Go project in 2023

boyter.org

31–40 of 205 posts

Re: How to start a Go project in 2023

#31

Genuine question.. I'll often see Golang pretty heavily criticized here on hacker news. Either that or people say it's a boring language and not worth learning when there is something more interesting (usually referring to Rust or Zig). Why does it have such a bad image? Personally i like it as an alternative for python because: 1. It can build binaries that just work for most architectures quickly. 2. It has nice c-…

It’s verbose. Errors everywhere.

There are a lot of foot guns. nil slice? Fine. nil map? Segfault. Loop variables with closures. The list goes on.

Generics seemingly split the community. May be some libraries won’t get used because they picked the wrong side.

It’s surprisingly weak at modeling data. Union types would really help out.

The community is so anti-design that it’s hard to play with them. Most want to make a big ball of mud and call it agile. When you point out simple patterns, they call you an Architect Astronaut. Checkout r/golang. Also look out for people telling you how dumb you are for wanting generics.

In many cases it’s a step backwards but it has the positives you posted. That is often a reason to grin and bear it. Eventually Stockholm Syndrome kicks in.

Re: How to start a Go project in 2023

#32

Genuine question.. I'll often see Golang pretty heavily criticized here on hacker news. Either that or people say it's a boring language and not worth learning when there is something more interesting (usually referring to Rust or Zig). Why does it have such a bad image? Personally i like it as an alternative for python because: 1. It can build binaries that just work for most architectures quickly. 2. It has nice c-…

HN loves playing "obligatory contrarian" so often commenters will go to lengths to find faults

there is nothing wrong with Go; it delivers on its promise, you don't need to be a genius to use it, has good community support, and you can get access to a large and decent job market

Rust is a great tool but isn't as purpose-suited to network services as Go

Zig is even less purpose-suited to writing network services and won't be at Go's level of maturity for years, if ever

If a backend dev could only know one language in 2023, it would be hard to go wrong with Go

Re: How to start a Go project in 2023

#33
post #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…

> There's no point in stripping a binary or even using UPX on it unless you're targeting extremely low memory environments

Deploing at a large enough scale, perhaps where other optimization options aren't as good or even available, could also be a target.

Re: How to start a Go project in 2023

#35

Genuine question.. I'll often see Golang pretty heavily criticized here on hacker news. Either that or people say it's a boring language and not worth learning when there is something more interesting (usually referring to Rust or Zig). Why does it have such a bad image? Personally i like it as an alternative for python because: 1. It can build binaries that just work for most architectures quickly. 2. It has nice c-…

It’s verbose. Errors everywhere. There are a lot of foot guns. nil slice? Fine. nil map? Segfault. Loop variables with closures. The list goes on. Generics seemingly split the community. May be some libraries won’t get used because they picked the wrong side. It’s surprisingly weak at modeling data. Union types would really help out. The community is so anti-design that it’s hard to play with them. Most want to make…

> Loop variables with closures

indeed a brutal footgun but will be fixed soon

Re: How to start a Go project in 2023

#36
post #25

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/…

Cobra is just so… intense and complicated. It has it's place but Google's Subcommands is enough for 99.9% of projects I've worked on - https://github.com/google/subcommands

hmm I recently just finish making a CLT with cobra and it wasn't too bad. Granted it's extremely basic but I like it for my use case (cloning all the repos in an org):

https://github.com/shimman-dev/piscator

What did you find complicated about it? What I struggle with is creating man pages automatically, although I did just find where in the repo this is explained.

subcommands does look neat tho, I'll likely use it for another tool I have in mind.

One thing I did not realize is that cobra and charmbracelet/bubbletea are not compatible. It may be my inexperience in making CLTs vs TUIs but I was disappointed I could use say the loading spinner from bubbles easily in my tool (opted for briandowns/spinner instead).

Re: How to start a Go project in 2023

#37

Genuine question.. I'll often see Golang pretty heavily criticized here on hacker news. Either that or people say it's a boring language and not worth learning when there is something more interesting (usually referring to Rust or Zig). Why does it have such a bad image? Personally i like it as an alternative for python because: 1. It can build binaries that just work for most architectures quickly. 2. It has nice c-…

Don’t worry about it. Your assessments are exactly correct.

I’m not putting down any other development environments, but everything you say is absolutely true in your circumstances (mine too).

Re: How to start a Go project in 2023

#38
post #19

[flagged]

What's "most modern languages"? Go is better than Python's native tooling (only Poetry and other similar 3rd party tools compare). Javascript I find unruly and fragmented. "Modern" C++ is still a nightmare.

Java I haven't touched but I don't exactly hear rave reviews or angry rants about, so I expect it's middling.

Rust, scala, and haskell are definitely better experiences, but they are definitely in the minority in terms of industry usage.

Go is not "quite bad", in fact far from it. I'd say it's better than average.

Re: How to start a Go project in 2023

#39
post #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…

vendoring is a bit of project smell, but for large teams it removes the confusion of who has what version of a dependency

unfortunately most teams don't schedule a periodic `go mod tidy` so you just end up with ancient deps

most people never read the code of the deps they pull in, so I don't think vendoring provides any security assurances

Post reply on HN