Can someone add letsencrypt.org ACME cert generation? https://godoc.org/golang.org/x/crypto/acme/autocert
Edit: found this https://gist.github.com/kennwhite/f9ea1afff776049974678fb21a...
This reminds me of an ongoing discussion I was having with friends about Golang web frameworks -- one side of the argument is that you can achieve so much with the standard library that frameworks are "unnecessary", but folk like me want an ORM(ish) layer and some kind of back-office scaffolding.
So... Any pointers on the latter? I can do an Ask HN, but this seems like a good context to ask in.
(Edited to add: why the downvotes? Is this not a legitimate question?)
Here's a quick attempt at the same thing in Java (although note that the command line format is different):
The main takeaway is that the JDK's built-in web server is poor:
* There is no way to configure timeouts
* Filters have to be added to each handler separately, by mucking with its filter list
* Filters have to extend an abstract class with two methods (one totally pointless), so you can't use lambdas for them
* Handlers use a simple string prefix match, so a request for "/healthzone" will hit the health handler
* The stop method always blocks for the specified timeout, and never returns early as the docs promise (IME)
Other minor irritations:
* There is no method to parse an InetSocketAddress from a string
* Java's support for handling clean process shutdown is not great; i think there's some sort of race between the shutdown hook and the logging system getting shut down, so you never see the "Server stopped" message
It's a nice reference program to show you what's going on.
I build stuff like this for a living. I'd recommend not re-inventing the wheel yourself and using a nice web framework, like Echo (https://github.com/labstack/echo) or Gin (https://github.com/gin-gonic/gin). I prefer Echo due to a cleaner, mockable design, but they're equivalent.
You can throw up that web server in 1/10 the code to do the same thing, and using built-in middleware is less work than writing your own.
Golang is self sufficient for a small scale web app.
It has HTML templates library, decent error handling, rpc, logging, built-in http server. Many people choose golang for that reason.
Thanks for this. I have been writing toy golang servers for a while to try out various ideas and this really helps clarify some useful techniques and best practices.
This is likely better posted as a Show HN if it meets the guidelines:
Small business loans for growth https://www.cityfinances.lv/kontakti/
So a hundred lines of pure boilerplate hooking up Go standard libraries, assumedly exactly how they were intended to be used. How is this news worthy?
Yea lets ditch everything we learned about modularization in the past 20 years and put everything in one single binary
Isn't Caddy written in Go? How is this different?
I do not quite see the point of this (other than being an exercise).
We already have web server that do "logging, tracing, health check, graceful shutdown." I do not care about zero deps, because I only install them once and the deps are taken care of by the package manager.
In my opinion, the Go web server only makes sense as part of a Go application as a whole. But a standalone Go web server does not make much sense to me.