Go

Start A New Program Language From scratch

Posted by Sage on June 21, 2021

To study a new language and apply it to project, it will not only require the functionality of the language, but also the practices.

Tutorial Guide or Book

A good book contains a lot of experiences.

search golang book

Checklist

Code Review Comments

https://golang.org/doc/effective_go
https://github.com/golang/go/wiki/CodeReviewComments

Secure Coding Practices

https://github.com/OWASP/Go-SCP

Open Source Projects

https://github.com/search?q=go&s=stars&type=Repositories

Development Tools

IDE

Goland

  • Project Structure keep the same structure with the $GOPATH for easy maintainance golang project structure

Multiple modules in one space

1
2
3
# Windows, run cmd with admin to link the module path to the git folder
cmd> mklink /D  "C:\Users\Lenovo\go\pkg\mod\git.ctyun.cn" "C:\Users\Lenovo\go\src\git.ctyun.cn"
cmd> mklink /D "C:\Users\Lenovo\go\src\git.company.com\modul-a@v1.0.2" "C:\Users\Lenovo\go\src\git.company.com\modul-a"

golang enable module golang default new line

  • Auto format

goland auto format

VSCode

Multiple modules in one space

https://github.com/golang/tools/blob/master/gopls/doc/workspace.md

Debug

1
2
dlv debug Chapter3/comma.go
b main.main

Package Management

1
2
3
4
5
6
7
8
# go get behind a proxy
go env -w GOPROXY="https://goproxy.cn,direct"

# go get without https source, like self-hosted gitlab
go env -w GOINSECURE=git.company.com

# go get with a private repo
go env -w GOPRIVATE=git.company.com

code scan

SonarQube

testing