.gitignore for Go
13 ignore rules for Go, ready to copy into your repository.
The Go programming language
The complete .gitignore for Go
# Generated by LFGitignore - https://lfgitignore.com
# Created: 2025-08-01 14:33:03 UTC
# Technologies: Go
### Go ###
# Windows executable
*.exe
*.exe~
# Dynamic link library
*.dll
# Shared object
*.so
# macOS dynamic library
*.dylib
*.test
# Compiler output
*.out
coverage.*
*.coverprofile
profile.cov
go.work
go.work.sum
# Environment variables
.env
What these Go rules actually ignore
Every pattern below, and why it belongs in your .gitignore.
Binaries for programs and plugins
| Pattern | What it ignores |
|---|---|
*.exe |
Windows executable |
*.exe~ |
Binaries for programs and plugins |
*.dll |
Dynamic link library |
*.so |
Shared object |
*.dylib |
macOS dynamic library |
Test binary, built with `go test -c`
| Pattern | What it ignores |
|---|---|
*.test |
Test binary, built with `go test -c` |
Code coverage profiles and other test artifacts
| Pattern | What it ignores |
|---|---|
*.out |
Compiler output |
coverage.* |
Code coverage profiles and other test artifacts |
*.coverprofile |
Code coverage profiles and other test artifacts |
profile.cov |
Code coverage profiles and other test artifacts |
Go workspace file
| Pattern | What it ignores |
|---|---|
go.work |
Go workspace file |
go.work.sum |
Go workspace file |
.env |
Environment variables |
How to use this .gitignore for Go
- Copy the Go rules above, or download the file directly.
- Create a file named .gitignore at the root of your Git repository and paste the rules into it.
- If some of those files are already tracked, run git rm -r --cached . then commit again — Git only applies ignore rules to untracked files.
- Commit the .gitignore so everyone on the team shares the same rules.