- Install Golang compiler
- Install Goland IDE
- Build helloworld app in Golang
- Where to start learning?
- Add 'go fmt' and checkstyle to Goland IDE
- Create sample project
- Auto generating unit test with gotest
To code Golang, you can use any IDE that is best convenient for you. For example Sublime, Vim, VS, Goland In my case, I would like to suggest to use Goland IDE because it is best Golang IDE at the time I write this blog. Link: https://www.jetbrains.com/go/
Golang tour will provide you some basic knowledges of Golang https://tour.golang.org/welcome/1 https://golang.org/doc/
Awesome list -> All of necessary libraries we may need then the link below can help you find a good enough library. Link: https://awesome-go.com/
Code review comment -> How to justify Golang code to review.
Link: https://github.com/golang/go/wiki/CodeReviewComments
‘go fmt’ is a tool of Golang being used to format Golang code. We can add this tool to Goland IDE to run this tool every time the file of code is saved.
checkstyle tool is a general tool to checking Golang code styles. We can change setting in it’s config file.
Steps:
Force common style rules:
{
"file_line":500,
"func_line":70,
"params_num":7,
"results_num":3,
"formated": true,
"pkg_name": true,
"camel_name": true,
"ignore":[
"testdata/*",
"temp/*"
],
"fatal":[
"formated",
"file_line",
"func_line",
"params_num",
"results_num",
"formated",
"pkg_name",
"camel_name"
]
}
Golang has built-in “testing” package. Which can help us creating unit test cases easily.
To generate test cases template automatically. We use this library:
https://github.com/cweill/gotests
- Setup
- Clone project
- Build gotests
-> Put the binary into somewhere of GOPATH or GOROOT paths.
In my case, I put it in GOROOT folder: C:\Users\andrew\go-1.10\bin\gotests.exe