go-tg-screenshot-bot
28 строк · 1.4 Кб
1I like to keep all my code to 80 columns or less. I have plenty of screen real
2estate, but enjoy 80 columns so that I can have multiple code windows open side
3to side and not be plagued by the ugly auto-wrapping of a text editor.
4
5If you don't oblige me, I will fix any patch you submit to abide 80 columns.
6
7Note that this style restriction does not preclude gofmt, but introduces a few
8peculiarities. The first is that gofmt will occasionally add spacing (typically
9to comments) that ends up going over 80 columns. Either shorten the comment or
10put it on its own line.
11
12The second and more common hiccup is when a function definition extends beyond
1380 columns. If one adds line breaks to keep it below 80 columns, gofmt will
14indent all subsequent lines in a function definition to the same indentation
15level of the function body. This results in a less-than-ideal separation
16between function definition and function body. To remedy this, simply add a
17line break like so:
18
19func RestackWindowExtra(xu *xgbutil.XUtil, win xproto.Window, stackMode int,
20sibling xproto.Window, source int) error {
21
22return ClientEvent(xu, win, "_NET_RESTACK_WINDOW", source, int(sibling),
23stackMode)
24}
25
26Something similar should also be applied to long 'if' or 'for' conditionals,
27although it would probably be preferrable to break up the conditional to
28smaller chunks with a few helper variables.
29
30