The project template of Golang.
gonew github.com/caitunai/go-blueprint@v1.8.1 github.com/yourname/project
go install golang.org/x/tools/cmd/gonew@latest
⚠️ You need edit the.golangci.yaml
file fordepguard
settings.
⚠️ Do not forget to replace the go module name in this.golangci.yaml
:Replace github.com/caitunai/go-blueprint to
github.com/yourname/project
.
install air
go install github.com/air-verse/air@latest
create the configuration and update the content
cp .app.toml.example .app.toml
vim .app.toml
then run project created by this template
air serve
lint the code
golangci-lint run
If it has some issues, try auto fix
golangci-lint run --fix
If it has issues about struct alignment, try this command to fix
fieldalignment -fix ./path/to/package
If the fieldalignment
command not found, you can install it with this command:
go install golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment@latest
After code style fixed, you can commit the code
git add .
git commit -m "commit_message"
GOOS=linux GOARCH=amd64 go build
Thanks