Git β€’ Languages & Frameworks

Go (Golang) .gitignore Template

Go compiles into standalone native binaries. This template ensures compiled executables (*.exe, *.dll, *.so), test output profiles, and local environment files remain untracked.

.gitignore(26 lines)
1# Compiled binaries
2bin/
3pkg/
4dist/
5
6# Executables
7*.exe
8*.exe~
9*.dll
10*.so
11*.dylib
12
13# Test binaries & coverage
14*.test
15*.out
16cover.out
17coverage.txt
18
19# Go workspace file (if not shared)
20go.work
21
22# Vendor folder (omit if using Go modules vendoring)
23# vendor/
24
25# Environment files
26.env

Key Rules & Why They Are Ignored

bin/ & *.exe

OS-specific compiled binaries generated by `go build`.

*.test & *.out

Test binary executables and coverage profile outputs from `go test -cover`.

Already Committed Ignored Files? Purge from Git Cache

Adding a pattern to .gitignore does NOT delete files that were already tracked in previous commits. Run this command to remove them from tracking without deleting your local copies:

git rm -r --cached . && git add . && git commit -m "Untrack ignored files"

Frequently Asked Questions About Go .gitignore

Frequently Asked Questions

Frequently Asked Questions

Everything you need to know regarding specifications, syntax, and security best practices.

Since Go 1.14+, `go.mod` and `go.sum` are standard and the `vendor/` directory is usually omitted unless building in an air-gapped network environment.