Skip to content

Instantly share code, notes, and snippets.

@riandyrn
Last active April 26, 2019 03:21
Show Gist options
  • Save riandyrn/0cdff7109d752f5acf1a6c3f368d5b0f to your computer and use it in GitHub Desktop.
Save riandyrn/0cdff7109d752f5acf1a6c3f368d5b0f to your computer and use it in GitHub Desktop.
Guidelines for Software Development Using Go

Go Development Guidelines

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:

  1. Define software requirements
  2. Create high-level architecture
  3. Create class diagram to identify relationship between classes (structs)
  4. Identify context / domain in the software, for example in Haraj Push Worker V2, we define 2 context: fetching & pushing
  5. Define dependencies on each context, make it portable using interface
  6. Develop the domain first, make domain portable as well using interface so it could be called on main using interface rather than concrete implementation
  7. Develop concrete implementation of domain dependencies
  8. Develop way to access the domain, either directly on main or from http handler, do this until we develop the main
  9. Implement testing for each domain
  10. Implement testing for domain dependencies if necessary
  11. Done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment