Go .gitignore Template
The full, current Go .gitignore template — copy it as-is, or head to the .gitignore Generator to merge it with other stacks into one file.
Template
# 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 *.out coverage.* *.coverprofile profile.cov # Dependency directories (remove the comment below to include it) # vendor/ # Go workspace file go.work go.work.sum # env file .env # Editor/IDE # .idea/ # .vscode/
What each entry does
Why every line in this template is excluded, not just what it matches.
| Entry | Why it's excluded |
|---|---|
| *.exe | A compiled native/Go/.NET executable — build output. |
| *.exe~ | Files matching *.exe~ — a generated or machine-specific file type for this stack, safe to regenerate rather than track. |
| *.dll | A compiled .NET/native binary — build output, not source. |
| *.so | A compiled Linux shared library — build output. |
| *.dylib | A compiled macOS dynamic library — build output. |
| *.test | Files matching *.test — a generated or machine-specific file type for this stack, safe to regenerate rather than track. |
| *.out | Files matching *.out — a generated or machine-specific file type for this stack, safe to regenerate rather than track. |
| coverage.* | Files matching coverage.* — a generated or machine-specific file type for this stack, safe to regenerate rather than track. |
| *.coverprofile | Files matching *.coverprofile — a generated or machine-specific file type for this stack, safe to regenerate rather than track. |
| profile.cov | Files matching profile.cov — a generated or machine-specific file type for this stack, safe to regenerate rather than track. |
| go.work | Files matching go.work — a generated or machine-specific file type for this stack, safe to regenerate rather than track. |
| go.work.sum | Files matching go.work.sum — a generated or machine-specific file type for this stack, safe to regenerate rather than track. |
| .env | Local environment variables — routinely holds real secrets (API keys, DB passwords), so it must never be committed. Commit a .env.example instead. |