This document contains my personal notes / guidelines to develop software using Go.
The main purpose of this document is to help myself remembering how to write good code using Go in the future. The reason is because I'm working not only using Go, but also other languages such as PHP, Python, & Javascript. Each of these languages has it own unique development guidelines, style, & mindset. So in order to not confuse Go development guidelines with anything, I decided to make this document.
So I found that the approach & mindset which work best for Golang (up until now) is Hexagonal Architecture.
Here is the list of such great talk for applying Hexagonal Architecture on Go:
Here is the list of such awesome repo for structuring Go code:
So here are my personal guidelines to develop software using Go:
- Define software requirements
- Create high-level architecture
- Create class diagram to identify relationship between classes (structs)
- Identify context / domain in the software, for example in
Haraj Push Worker V2
, we define 2 context:fetching
&pushing
- Define dependencies on each context, make it portable using interface
- Develop the domain first, make domain portable as well using interface so it could be called on main using interface rather than concrete implementation
- Develop concrete implementation of domain dependencies
- Develop way to access the domain, either directly on main or from http handler, do this until we develop the main
- Implement testing for each domain
- Implement testing for domain dependencies if necessary
- Done