Live data from Hacker News

Some Go web dev notes

jvns.ca

131–140 of 154 posts

Re: Some Go web dev notes

#131

Earlier quoted context omitted.

I really don't understand the hate for a framework in "the community". I had stayed away from Go for about 3 years and I posted on r/golang asking if anything had popped up like a django in go and got nothing but hate. I chock it up to people enjoy writing the same boiler plate stuff over and over in their paid jobs where they have the time to do it. To your point, I've got my own set of libraries that I think are Th…

Hey, I checked your Reddit thread [1] and I see a good discussion with useful suggestions. I don't see "anything but hate" at all. There are pros and cons to using frameworks. True, many people seem to prefer to use smaller libraries. I personally don't like magic because sooner or later I lose track of what's going on and need to start guessing. With direct code I can understand faster without having to read docs an…

Fair. Maybe this is good evidence of my naturally pessimistic disposition. I was quite active with the initial replies and didn't feel like it was giving any credit to a framework.

Re: Some Go web dev notes

#132

I've been using go for a month now in a new job and hate it. It feels like they learned nothing from the past 20 years of language development. Just one huge problem is that they REPEATED Java's million/billion dollar mistake with nulls. The usual way to get HTTP Headers using Go cannot distinguish between an empty header value and no header at all because the method returns "nil" for both these cases. They could've…

I hate that they made and popularized this backwards dumpster fire ..

Well I think you should hate the fact that other language authors despite using better programming paradigm and using advancement in last 2 decades have not been able popularize their efforts enough to wipe out Go.

Go devs did what they did and made it open source. And from what I see they did not do any relentless marketing to make it popular.

Re: Some Go web dev notes

#133
post #109
post #93

Earlier quoted context omitted.

I've grown to prefer go-chi over Gin (or Echo), since it's just the standard library with some QoL features on top.

I like it, but with the new http.ServeMux rolled out in Go 1.22, is there any use for Chi anymore?

Good question. The middleware stack it provides is nice.

Re: Some Go web dev notes

#134

I've been using go for a month now in a new job and hate it. It feels like they learned nothing from the past 20 years of language development. Just one huge problem is that they REPEATED Java's million/billion dollar mistake with nulls. The usual way to get HTTP Headers using Go cannot distinguish between an empty header value and no header at all because the method returns "nil" for both these cases. They could've…

I don't think your example is very compelling but I completely agree with your general point. I read the Go book by Donovan and Kernighan and I have been working full-time in Go for the last year (my work is otherwise interesting so this is tolerable). It is painfully obvious that the authors are stuck in 1986 in terms of language design. Go is C with modernized tooling (in some ways it's worse...). It's a horrible i…

> people with imperative language brain damage to learn, ..

Perhaps this attitude is why function languages are not as popular as they could be.

Re: Some Go web dev notes

#135
post #98
post #93

Earlier quoted context omitted.

I've grown to prefer go-chi over Gin (or Echo), since it's just the standard library with some QoL features on top.

Chi is amazing. I love the philosophy of extending the stdlib instead of writing an alternative. I try to keep that in mind when writing my own libs or helpers now, and I'm very satisfied with the results. For example I made a lib to write commands (like cobra or urfave/cli), but based entirely on the `flag` package: https://github.com/Thiht/go-command

> For example I made a lib to write commands (like cobra or urfave/cli), but based entirely on the `flag` package: https://github.com/Thiht/go-command

Looks nice! I'd like an easier way of setting both long and short flags for a command, i.e. --verbose and -v should do the same. Using `flag` I have to declare everything twice to achieve this.

Re: Some Go web dev notes

#136

Earlier quoted context omitted.

This looks excellent! The go tools for managing DB schema migrations have always felt lacking to me, and it seems like your tool ticks all of the boxes I had. Except for one: lack of support for CREATE INDEX CONCURRENTLY (usually done by detecting that and skipping the transaction for that migration). How do you handle creating indexes without this?

Thanks for taking a look! Long-running index creation is a problem for pgmigrate and anyone else doing “on-app-startup” or “before-app-deploys” migrations. Even at moderate scale (normal webapp stuff, not megaco size) building indexes can take a long time — especially for the tables where it’s most important to have indexes. But if you’re doing long-running index building in your migrations step, you can’t deploy a n…

I think that’s the safest approach, but it’s inconvenient for the common case of an index that’ll be quick enough in practice.

The approach I’ve seen flyway take is to allow detecting / opting out of transactions on specific migrations

As long as you always apply migrations before deploying and abort the deploy if they time out or fail, then this approach is perfectly safe.

On the whole I think flyway does a decent job of making the easy things easy and the harder things possible - it just unfortunately comes with a bunch JVM baggage - so a Go based tool seems like a good alternative

Re: Some Go web dev notes

#137
post #20

> I learned the hard way that if I don’t do this then I’ll get SQLITE_BUSY errors from two threads trying to write to the db at the same time. OK, here's a potentially controversial opinion from someone coming into the web + DB field from writing operating systems: 1. Database transactions are designed to fail Therefore 2. All database transactions should done in a transaction loop Basically something like this: http…

You'll just end up looping until your retry limit is reached. SQLite just isn't very good at upgrading read locks to write locks, so the appropriate fix really is to prevent that from happening.

I've needed the exact same loop on (an older) Postgres to stop production from hitting transient errors. It's fundamental to the concept of concurrent interactive transactions.

Re: Some Go web dev notes

#138

I've been using go for a month now in a new job and hate it. It feels like they learned nothing from the past 20 years of language development. Just one huge problem is that they REPEATED Java's million/billion dollar mistake with nulls. The usual way to get HTTP Headers using Go cannot distinguish between an empty header value and no header at all because the method returns "nil" for both these cases. They could've…

I don't think your example is very compelling but I completely agree with your general point. I read the Go book by Donovan and Kernighan and I have been working full-time in Go for the last year (my work is otherwise interesting so this is tolerable). It is painfully obvious that the authors are stuck in 1986 in terms of language design. Go is C with modernized tooling (in some ways it's worse...). It's a horrible i…

Go does have const: https://go.dev/tour/basics/15

Re: Some Go web dev notes

#139
post #69

Does she (or anyone else here) use net/http's built in https support? Seems implied by saying the built-in web server is used in production.

Yes, all the time! The built-in net/http has great TLS support https://eli.thegreenplace.net/2021/go-https-servers-with-tls...

Is it the norm to use the go server behind something else, I'm implying, I guess.

Re: Some Go web dev notes

#140

I've been using go for a month now in a new job and hate it. It feels like they learned nothing from the past 20 years of language development. Just one huge problem is that they REPEATED Java's million/billion dollar mistake with nulls. The usual way to get HTTP Headers using Go cannot distinguish between an empty header value and no header at all because the method returns "nil" for both these cases. They could've…

Not to talk about the lack of sake error handling in Go.

Saké is rarely an error.
Post reply on HN