Skip to content

coke5151/go-project-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go (Golang) Project Template

A go (golang) project template with Air (Hot reloading tool) and VSCode settings

This project also turn on some inlay hints in VSCode. You can preview with cmd/inlayhints/main.go.

You can also turn it off by changing/deleting the settings.json file in .vscode folder whenever you want.

Initial Setup

go mod init github.com/your-username/your-project-name # initialize the project
go install github.com/air-verse/air@latest # install air
air init # initialize air

Air

Air is a tool for building and reloading your go application.

Your air.toml file may look like this:

root = "."
testdata_dir = "testdata"
tmp_dir = "tmp"

[build]
  args_bin = []
  bin = "tmp\\main.exe"
  cmd = "go build -o ./tmp/main.exe ."
  delay = 1000
  exclude_dir = ["assets", "tmp", "vendor", "testdata"]
  exclude_file = []
# ...

change the cmd command to the path you want to run currently.

for example, to run cmd/inlayhints/main.go, edit the .air.toml file:

[build]
  cmd = "go build -o ./tmp/main.exe ./cmd/inlayhints/main.go"

You only need to run the command air in the root of your project to start hot reloading.

About

A go (golang) project template with Air and VSCode settings

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages