github/gitignore · Go.gitignore

Go .gitignore 템플릿 해설

Go.gitignore가 바이너리, 테스트 바이너리, 커버리지 프로필, go.work를 무시하는 이유와 확장자 없는 실행 파일을 따로 막아야 하는 이유를 설명합니다.

생성기에서 열기 JetBrains, VisualStudioCode, macOS, Linux 함께 열기

Go.gitignore는 빌드 결과 바이너리와 테스트·커버리지 산출물, 그리고 로컬 워크스페이스 파일을 다룬다. Go는 의존성을 모듈 캐시($GOPATH/pkg/mod)에 받기 때문에 Node의 node_modules 같은 거대한 폴더가 저장소 안에 생기지 않고, 템플릿도 짧다.

go.modgo.sum은 무시 대상이 아니다. 두 파일은 모듈의 의존성과 체크섬을 기록하므로 반드시 커밋한다.

규칙별 해설

패턴무엇을, 왜 무시하나
*.exe*.exe~*.dll*.so*.dylib바이너리·라이브러리go build 결과와 cgo로 만든 공유 라이브러리다. 플랫폼마다 따로 빌드되므로 저장소가 아니라 릴리스 산출물로 배포한다.
*.test테스트 바이너리go test -c로 만든 테스트 실행 파일이다. 패키지 이름 뒤에 .test가 붙는다.
*.outcoverage.**.coverprofileprofile.cov커버리지·프로파일go test -coverprofile=coverage.out 같은 명령이 만드는 결과다. 매 실행마다 달라지는 측정값이다.
go.workgo.work.sum워크스페이스여러 모듈을 로컬에서 함께 개발할 때 쓰는 파일로, 내 디스크의 경로를 가리킨다. go help work 문서도 go.work를 버전 관리에 넣는 것은 일반적으로 권하지 않는다고 설명한다.
.env환경 변수로컬 설정과 비밀 값을 담는 파일이다. 예시 파일은 다른 이름(예: .env.example)으로 커밋한다.

실무에서 주의할 점

원본 템플릿

Go.gitignore규칙 13줄
# 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*.outcoverage.**.coverprofileprofile.cov# Dependency directories (remove the comment below to include it)# vendor/# Go workspace filego.workgo.work.sum# env file.env# Editor/IDE# .idea/# .vscode/

템플릿 출처: github/gitignore/Go.gitignore @356fd7b (2026-09-11) · CC0-1.0

함께 쓰는 템플릿

다른 템플릿 해설