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 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 using 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. === Libraries
  27. - https://github.com/gorilla/mux[gorilla/mux], HTTP request router and dispatcher
  28. - https://github.com/gorilla/csrf[gorilla/csrf], CSRF middleware
  29. - https://github.com/jamiealquiza/envy/[envy], exposes flags as environment variables
  30. - https://github.com/guregu/null[null], defines nullable types for use with both SQL and JSON
  31. === Useful references
  32. - https://dave.cheney.net/practical-go/presentations/qcon-china.html[Practical Go]:
  33. "Real world advice for writing maintainable Go programs"
  34. - https://leanpub.com/productiongo/read[Production Go] book