You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

golang.adoc 858B

1234567891011121314151617181920212223242526272829303132333435363738
  1. +++
  2. +++
  3. :source-highlighter: pygments
  4. :source-language: go
  5. == Golang
  6. https://golang.org/[Golang] is a modern programming language that can
  7. compiles to static binaries for most common platforms. This can result
  8. in incredibly small docker images as you can build it from `scratch`.
  9. I'm increasing usling Golang in favour of Java, Kotlin or Python for
  10. writing services.
  11. === Handling interrupts
  12. Use the `signal` package to receive signals and put them
  13. into a channel:
  14. [source]
  15. ----
  16. c := make(chan os.Signal, 1)
  17. signal.Notify(c, os.Interrupt)
  18. signal.Notify(c, syscall.SIGTERM)
  19. ----
  20. Then at the end of the main method you can perform a
  21. blocking read on the channel:
  22. [source]
  23. ----
  24. <-c
  25. ----
  26. === Useful references
  27. - https://dave.cheney.net/practical-go/presentations/qcon-china.html[Practical Go]:
  28. "Real world advice for writing maintainable Go programs"