github/gitignore · Go.gitignore

Go .gitignore Template Explained

Why Go.gitignore ignores binaries, test binaries, coverage profiles and go.work, and why extensionless executables need a separate rule.

Open in generator Open with JetBrains, VisualStudioCode, macOS, Linux

Go.gitignore covers built binaries, test and coverage output, and local workspace files. Because Go downloads dependencies into the module cache ($GOPATH/pkg/mod), no huge folder like Node's node_modules appears inside the repository, and the template is short.

go.mod and go.sum are not ignored. These two files record the module's dependencies and checksums, so always commit them.

Rules explained

PatternWhat it ignores and why
*.exe*.exe~*.dll*.so*.dylibBinaries and librariesOutput of go build and shared libraries built with cgo. They are built separately for each platform, so distribute them as release artifacts rather than through the repository.
*.testTest binariesTest executables created with go test -c. The package name is followed by .test.
*.outcoverage.**.coverprofileprofile.covCoverage and profilesResults produced by commands such as go test -coverprofile=coverage.out. They are measurements that change on every run.
go.workgo.work.sumWorkspacesFiles used when developing several modules together locally; they point to paths on your own disk. The go help work documentation also explains that checking go.work into version control is generally not recommended.
.envEnvironment variablesA file holding local settings and secret values. Commit example files under a different name (for example, .env.example).

Practical notes

Original template

Go.gitignore13 rules
# If you prefer the allow list template instead of the deny list, see community template:# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore## Binaries for programs and plugins*.exe*.exe~*.dll*.so*.dylib# Test binary, built with `go test -c`*.test# Code coverage profiles and other test artifacts*.outcoverage.**.coverprofileprofile.cov# Dependency directories (remove the comment below to include it)# vendor/# Go workspace filego.workgo.work.sum# env file.env# Editor/IDE# .idea/# .vscode/

Templates from github/gitignore/Go.gitignore @356fd7b (2026-09-11) · CC0-1.0

Often used together

More template explanations