Some best and bad practices by Anthony Alaribe at Golang Nigeria.
Highlights:
- Closures vs methods for dependency injection
- Errors are values
- Using function adapters in Go
How to Troubleshoot Apps for the Modern Connected Worker
Go best (and bad) practices
1. Go Best and Bad
Practices
LAGOS, NG. 18 AUGUST, 2018
Anthony Alaribe
Opera (Opay team)
@tonyalaribe
2. Today’s (glorious) blather.
Handle errors first 01
Use Function adapters
Closures vs Methods
Errors are values
A Concurrency Gotcha
02
03
04
05
3. How to write code that is:
02. A SIMPLE TYPE SYSTEM
- Simple
- Maintainable
- Readable (Yet powerful)
4. Disclaimer
02. A SIMPLE TYPE SYSTEM
- This talk is based of a lot of other
resources in the community from
people like
- Francis Campoy,
- Robe Pike,
- Steve Francia, etc
21. NOTE
03. METHODS VS CLOSURES
r.Mount("/api/todo",
todo.Routes(configuration))
Things to Note:
The smaller code surface area.
Using closures, the code feels
more compact
(and in my opinion, elegant).
functionA(argA)(argB)(argC)
Closures can be a little less
unnatural, since you can have
scenarios such as
27. Debugging is twice as hard as writing the
code in the first place. Therefore, if you
write the code as cleverly as possible,
you are, by definition, not smart enough
to debug it.
BRIAN KERNIGHAN