Skip to content

caitunai/go-blueprint

Repository files navigation

Go-Blueprint

The project template of Golang.

How to use

gonew github.com/caitunai/go-blueprint@v1.8.1 github.com/yourname/project

Install gonew

go install golang.org/x/tools/cmd/gonew@latest

⚠️ Update the hardcode

⚠️ You need edit the .golangci.yaml file for depguard 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.

Develop and Run

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 code and commit

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"

Build to release

GOOS=linux GOARCH=amd64 go build

Thanks

About

The project template of Golang.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages