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 |
| 2 | bin/ |
| 3 | pkg/ |
| 4 | dist/ |
| 5 | |
| 6 | # Executables |
| 7 | *.exe |
| 8 | *.exe~ |
| 9 | *.dll |
| 10 | *.so |
| 11 | *.dylib |
| 12 | |
| 13 | # Test binaries & coverage |
| 14 | *.test |
| 15 | *.out |
| 16 | cover.out |
| 17 | coverage.txt |
| 18 | |
| 19 | # Go workspace file (if not shared) |
| 20 | go.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/ & *.exeOS-specific compiled binaries generated by `go build`.
*.test & *.outTest 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.
Related .gitignore Templates
View All TemplatesLanguages & Frameworks
Node.js .gitignore Template
46 linesTemplate β
Languages & Frameworks
Python .gitignore Template
59 linesTemplate β
Languages & Frameworks
React & Next.js .gitignore Template
30 linesTemplate β
Languages & Frameworks
Rust & Cargo .gitignore Template
11 linesTemplate β
Languages & Frameworks
Java (Maven & Gradle) .gitignore Template
38 linesTemplate β
Operating Systems
macOS System Files (.DS_Store) .gitignore Template
19 linesTemplate β