I'm following along Nick Jackson's Building Microservices with Go series on YouTube.
I love his style of teaching.
I started using Go since Apr 2021, but mostly with AWS SDK for Go V2 and Lambda in Go.
Come to think of it, my previous project was also a serverless one on AWS, but with Javascript.
So last time I developed commerical container-based system was around 2019-2020. And it was a monolith server backed by TypeScript, Node.js, PostgreSQL, and of course, Kubernetes. We ran into the textbook Monolith Hell, a prevailing architecture struggle described in Chris Richardson's book Microservices Patterns. I'm reading this book by the way.
- learn more Go
- brush up building REST APIs
- learn gRPC
- last but not least: learn Nick Jackson's style of teaching
- 2021-09-12: init commit!
- 2021-09-12: ep-01 hello world http server
- 2021-09-14: ep-02 refactor to http handler modules. shut down server gracefully
- 2021-09-14: ep-03 basic REST api
- 2021-09-16: ep-04 basic REST api CRUD
- 2021-09-26: ep-05 use Gorilla Mux to bootstrap REST routes. it is very similar to express.js.
- 2021-10-02: ep-06 use Go validator to validate REST request input. it is a different approach from joi, where the validation rules are tied with HTTP handler middleware.
- 2021-10-04: ep-07 generate Swagger API docs.
- 2021-10-09: ep-08 generate API client from Swagger spec.
- 2021-10-09: ep-09 more gorilla handler/middleware.
-
auto-compile and re-start the server on file changes. unlike Javascript, Go community doesn't seem to have a go-to solution.
# https://techinscribed.com/5-ways-to-live-reloading-go-applications/ npx nodemon --exec go run main.go --signal SIGTERM
-
run go tests recursively in all sub directories
go test -v ./...
-
go channel
-
go signal: https://gobyexample.com/signals
-
Go Struct tag: I've been using it without knowing it has a name. I really like how easy it makes JSON parse/encode with data object
-
Gorilla Mux: Gorilla Mux to Golang feels like Express.js to Node.js
-
Gorilla hanlders: some logging middleware
-
go test -v ./...: run go test recursively in all sub directories
-
goswagger: Generates a swagger specification from annotated go code goswagger spec generation rules
-
swagger ui: a more commonly used Swagger doc server
-
Let's Go - Routing Requests: I wanted to do wildcard routing, i.e.: /products/*, it turned out I just needed to use /products/ with a slash at the end, it's Subtree Pattern
-
how to merge 2 structs with same type: I wish I could have something equivalent to Javascript spread:
c = {...a, ...b}
-
fmt.Errorf vs errors.New: I'm still not quite clear, need to read this PDF