Live data from Hacker News

How I write HTTP services in Go after 13 years

grafana.com

1–10 of 259 posts

Re: How I write HTTP services in Go after 13 years

#5

What is the value making main.go as small as possible? Whose dreams come true in this scenario?

Usually your main function can't be used by any other part of your program. You should move all component implementations to modules so they can be re-used elsewhere.

Re: How I write HTTP services in Go after 13 years

#6

What is the value making main.go as small as possible? Whose dreams come true in this scenario?

“Whose dreams come true in this scenario?”

I love this! I will use this as well.

There are so many situations where I have a feeling that people are solving problems that don’t exist. In code I run into at work, code and projects I see online, etc

The “whose dreams are you making come true” really applies here, because dreams are exactly what they are.

I spent quite some time writing an automatic image resizer and optimiser for my blog. Does it matter? No! Should I have spent that time writing blog posts instead? Yes! Still I was chasing some dream.

Thanks for this image

Re: How I write HTTP services in Go after 13 years

#8

What is the value making main.go as small as possible? Whose dreams come true in this scenario?

For bespoke internal services, I like to keep main.go as flat as reasonable, like a "script". Handlers can have their own files but the bulk of the control flow and moving parts should be apparent from reading the main file.

Abstracting things away from main makes it less readable and is general pointless for bespoke services that will be deployed in exactly one configuration.

Post reply on HN