Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Sorry for a question that is not directly related to the blog post, but anyway. CockroachDB is the only Go project I'm aware of that uses `2 spaces` indentation instead of `tab`s. I'm curious, is there any reason for that?


(Cockroach Labs co-founder here) The source files contain tab characters (gofmt enforces this for all go projects). We configure our editors to render tabs as two spaces. There's no deep reason for this; we've just gotten used to two-space indents from our time at Google and other projects that used this convention.

Since Go code is formatted with tabs, you can mostly get away with setting the indentation to whatever you want. The one practical problem with letting people choose their own values for the width of a tab is that it becomes tricky to enforce a uniform line length, so we've standardized on two-space indents (and 100-char line lengths) across the project.


Thanks, now I see those are tabs. I didn't know Github indentation style is customizable. Interesting.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: