Hi Go team,
1) It's odd to me that official documentation uses Gin (one of many web frameworks), rather than showcasing the Go standard library. It'd be a few more lines of code, but not many.
2) The in-memory database implementation isn't concurrency-safe. I realize it's "just" a tutorial, but it'd be nice if the code at least wasn't buggy (it just needs a mutex around accesses to "albums").
3) There's no validation when adding albums, allowing things like empty IDs, duplicate IDs, and so on.
4) Other things that may be out of scope for the tutorial: for example defining a Database interface to provide a separation of concerns instead of mixing "database" code in with the handlers.
Is there any interest in making any or all of these improvements? Or moving from Gin to the stdlib? I'm not saying to use my version directly, as I think that's more than what would be needed in a tutorial like this, but I think it'd be good to at least consider updating it to fix the race condition. Optionally, we could add validation, consider using only the stdlib, and make some of the other updates I've done in my version.
After discussion of what's in scope, I'd be interested in submitting a CL.
Thoughts?
-Ben