# 뱅크샐러드 Go 코딩 컨벤션

> Clean Markdown view of GeekNews topic #10889. Use the original source for factual precision when an external source URL is present.

## Metadata

- GeekNews HTML: [https://news.hada.io/topic?id=10889](https://news.hada.io/topic?id=10889)
- GeekNews Markdown: [https://news.hada.io/topic/10889.md](https://news.hada.io/topic/10889.md)
- Type: news
- Author: [winterjung](https://news.hada.io/@winterjung)
- Published: 2023-09-15T12:43:49+09:00
- Updated: 2023-09-15T12:43:49+09:00
- Original source: [blog.banksalad.com](https://blog.banksalad.com/tech/go-best-practice-in-banksalad/)
- Points: 38
- Comments: 3

## Topic Body

* 뱅크샐러드팀이 4년간 Go를 활발히 사용하며 다양한 실수와 시행착오를 겪으며 정해나간 코딩 컨벤션  
  
#### 읽어두면 좋은 자료  
  
한 번 읽어보길 권장하는 여러 컨벤션 가이드와 best practices 자료  
  
* [The Zen of Go](https://the-zen-of-go.netlify.app/)  
  * 각 구절의 상세한 설명: [The Zen of Go | Dave Cheney](https://dave.cheney.net/2020/02/23/the-zen-of-go)  
  * 한국어 번역 [Go의 철학 | marsettler.com](https://marsettler.com/go/the-zen-of-go/)  
* [Go Proverbs](https://go-proverbs.github.io/)  
* [Effective Go | go.dev](https://go.dev/doc/effective_go)  
* [CodeReviewComments · golang/go Wiki | GitHub](https://github.com/golang/go/wiki/CodeReviewComments)  
* [Practical Go | Dave Cheney](https://dave.cheney.net/practical-go)  
* Thanos 팀 스타일 가이드([한국어](https://github.com/zzerjae/thanos-coding-style-guide-kr), [원문](https://thanos.io/tip/contributing/coding-style-guide.md/))  
* Uber 팀 스타일 가이드([한국어](https://github.com/TangoEnSkai/uber-go-style-guide-kr), [원문](https://github.com/uber-go/guide/blob/master/style.md))  
* [Ashley McNamara + Brian Ketelsen. Go best practices | YouTube](https://www.youtube.com/watch?v=MzTcsI6tn-0)  
* [Idiomatic Go | Sourcegraph](https://about.sourcegraph.com/blog/go/idiomatic-go)  
* [Go Style Best Practices | Google](https://google.github.io/styleguide/go/best-practices.html)  
  
#### 코딩 프랙티스  
  
* Don't panic  
* Panic을 낼 수 있는 함수는 must prefix 붙이기 / Panic vs Fatal  
* Panic safe goroutine / Concurrent safe한 결과 모으기  
* Error stacking / Error handling / Error logging  
* No named return  
* HTTP client 설정 / HTTP connection 재사용  
* Slice 선언 시 len, cap 설정 / Nil slice vs Empty slice  
* Bool map과 struct{} map / Map 조회 시 ok 체크 / Avoid map loop  
* 문자열  loop 시 range 사용 / 문자열 길이  
* `context.TODO()` 보다 `context.Background()` 사용  
* Early return 애용  
* `time.Duration` 사용 / 타임존  
* 테이블 기반 테스트 / No monkey patch / Deterministic test  
* Avoid reflect  
* Functional options  
  
#### 코딩 스타일  
  
서술된 내용은 뱅크샐러드 팀의 스타일로 각 항목은 그대로 따르기보단 각 조직에 맞게 고려하길 권장  
  
* 함수의 인자 순서  
* 테스트 함수 네이밍  
* 파일 내 선언 순서  
* import 순서  
* 단수는 get 복수는 list  
* 모호한 단어 피하기  
* const 네이밍  
* 패키지 네이밍  
* 프로젝트 구조

## Comments



### Comment 19231

- Author: [deleted]
- Created: 2023-09-15T16:12:36+09:00
- Points: 1

[삭제된 댓글입니다]

### Comment 19245

- Author: zxgdot
- Created: 2023-09-15T19:55:31+09:00
- Points: 1
- Parent comment: 19231
- Depth: 1

:woman_running:

### Comment 19226

- Author: secret3056
- Created: 2023-09-15T12:59:27+09:00
- Points: 1

좋은 글 잘 읽었습니다. 국내에서 Go를 가장 잘 활용하는 두 기업이 뱅샐이랑 AB180이라고 생각합니다.
