1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- +++
- +++
-
- :source-highlighter: pygments
- :source-language: go
-
- == Golang
-
- https://golang.org/[Golang] is a modern programming language that can
- compiles to static binaries for most common platforms. This can result
- in incredibly small docker images as you can build it from `scratch`.
-
- I'm increasing using Golang in favour of Java, Kotlin or Python for
- writing services.
-
- === Handling interrupts
-
- Use the `signal` package to receive signals and put them
- into a channel:
-
- [source]
- ----
- c := make(chan os.Signal, 1)
- signal.Notify(c, os.Interrupt)
- signal.Notify(c, syscall.SIGTERM)
- ----
-
- Then at the end of the main method you can perform a
- blocking read on the channel:
-
- [source]
- ----
- <-c
- ----
-
- === Libraries
-
- - https://github.com/gorilla/mux[gorilla/mux], HTTP request router and dispatcher
- - https://github.com/gorilla/csrf[gorilla/csrf], CSRF middleware
- - https://github.com/jamiealquiza/envy/[envy], exposes flags as environment variables
- - https://github.com/guregu/null[null], defines nullable types for use with both SQL and JSON
-
- === Useful references
-
- - https://dave.cheney.net/practical-go/presentations/qcon-china.html[Practical Go]:
- "Real world advice for writing maintainable Go programs"
- - https://leanpub.com/productiongo/read[Production Go] book
|