You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+17-17Lines changed: 17 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,6 +36,17 @@ If no paths are provided, then input is taken from `stdin` (as with `gofmt`).
36
36
By default, the results are printed to `stdout`.
37
37
To overwrite the existing files in place, use the `-w` flag.
38
38
39
+
## Examples
40
+
41
+
See this [before](/shorten/testdata/end_to_end/end_to_end.go) and [after](/shorten/testdata/end_to_end/end_to_end.go.golden) view of a file with very long lines.
42
+
More example pairs can be found in the [`testdata`](/shorten/testdata) directory.
43
+
44
+
## Limitations
45
+
46
+
The tool has been tested on a variety of inputs, but it's not perfect.
47
+
Among other examples, the handling of long lines in comments could be improved.
48
+
If you see anything particularly egregious, please report it via an issue.
49
+
39
50
## Options
40
51
41
52
Some other options are described in the sections below.
@@ -47,31 +58,31 @@ By default, the tool tries to shorten lines that are longer than 100 columns
47
58
and assumes that 1 tab = 4 columns.
48
59
The latter can be changed via the `-m` and `-t` flags respectively.
49
60
50
-
####Dry-run mode
61
+
### Dry-run mode
51
62
52
63
Running the tool with the `--dry-run` flag will show pretty, git-style diffs.
53
64
54
-
####Comment shortening
65
+
### Comment shortening
55
66
56
67
Shortening long comment lines is harder than shortening code
57
68
because comments can have arbitrary structure and format.
58
69
`golines` includes some basic logic for shortening single-line (i.e., `//`-prefixed) comments,
59
70
but this is turned off by default since the quality isn't great.
60
71
To enable this feature anyway, run with the `--shorten-comments` flag.
61
72
62
-
####Custom formatters
73
+
### Custom formatters
63
74
64
75
By default, the tool will use [`goimports`](https://godoc.org/golang.org/x/tools/cmd/goimports)
65
76
as the base formatter (if found), otherwise it will revert to `gofmt`.
66
77
An explicit formatter can be set via the `--base-formatter` flag;
67
78
the command provided here should accept its input via `stdin` and write its output to `stdout`.
68
79
69
-
####Generated files
80
+
### Generated files
70
81
71
82
By default, the tool will not format any files that look like they're generated.
72
83
If you want to reformat these too, run with the flag `--ignore-generated=false`.
73
84
74
-
####Chained method splitting
85
+
### Chained method splitting
75
86
76
87
There are several possible ways to split lines that are part of
The original behavior can be used by running the tool with the
103
114
`--no-chain-split-dots` flag.
104
115
105
-
####Struct tag reformatting
116
+
### Struct tag reformatting
106
117
107
118
In addition to shortening long lines, the tool also aligns struct tag keys;
108
119
see the associated [before](shorten/testdata/struct_tags/struct_tags.go)
@@ -193,11 +204,6 @@ like the one above, according to their preferences.
193
204
194
205
More background and technical details are available in [this blog post](https://yolken.net/blog/cleaner-go-code-golines).
195
206
196
-
## Examples
197
-
198
-
See this [before](/shorten/testdata/end_to_end/end_to_end.go) and [after](/shorten/testdata/end_to_end/end_to_end.go.golden) view of a file with very long lines.
199
-
More example pairs can be found in the [`testdata`](/shorten/testdata) directory.
200
-
201
207
## How It Works
202
208
203
209
For each input source file, `golines` runs through the following process:
@@ -217,9 +223,3 @@ For each input source file, `golines` runs through the following process:
217
223
`stdout` or the source file
218
224
219
225
See [this blog post](https://yolken.net/blog/cleaner-go-code-golines) for more technical details.
220
-
221
-
## Limitations
222
-
223
-
The tool has been tested on a variety of inputs, but it's not perfect.
224
-
Among other examples, the handling of long lines in comments could be improved.
225
-
If you see anything particularly egregious, please report it via an issue.
0 commit comments