1234567891011121314151617181920212223242526272829303132333435363738 |
- +++
- +++
- :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 usling 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
- ----
-
- === Useful references
-
- - https://dave.cheney.net/practical-go/presentations/qcon-china.html[Practical Go]:
- "Real world advice for writing maintainable Go programs"
|