.gitignore for Go

Go build output, test binaries, and Go module download cache.

Quick presets

Selected (1)
Go
Your selections never leave your browser. Generation happens entirely client-side.
Raw

10 patterns · 205 B

# Generated by DevZone Tools — https://devzone.tools/tools/gitignore-generator
# Templates: Go
# 2026-04-20

# ---- Go ----
# Go
*.exe
*.exe~
*.dll
*.so
*.dylib
*.test
*.out
go.work
go.work.sum
/vendor/

What this template ignores

Ignores compiled Go binaries (*.exe, *.out), test binaries (*.test), shared libraries, and the vendor/ directory if using go mod vendor.

Common additions

  • +.env — environment variable files
  • +bin/ — if you output binaries to a local bin/ directory

Commonly paired with

Frequently asked questions

Do I need to commit .gitignore?
Yes — .gitignore should be committed to the repository so all collaborators benefit from the same ignore rules.
How do I add custom patterns?
Open your .gitignore file and add the pattern on a new line. Use # for comments, * for wildcards, / to match directories, and ! to un-ignore a previously ignored path.
How do I ignore a file that is already tracked?
Adding a file to .gitignore does not remove it from tracking if it was previously committed. Run: git rm --cached <file> to stop tracking it without deleting the file locally.
Should I commit go.sum?
Yes — go.sum contains cryptographic checksums of module dependencies and should always be committed to ensure reproducible builds.
Should I commit vendor/?
It depends. Vendoring is common in Go for reproducibility without a module proxy. If you use go mod vendor, commit vendor/. Otherwise ignore it.

Looking for something else? Browse all templates →