![]() To turn this behavior off, run with -no-reformat-tags. In addition to shortening long lines, the tool also aligns struct tag keys see theĮxamples in the _fixtures directory. The original behavior can be used by running the tool with the -no-chain-split-dots Starting in version 0.3.0, the tool now splits on the dots by default, e.g.: myObj.Method(arg1, arg2, arg3). There are several possible ways to split lines that are part ofĪpproach taken by golines was to split on the args, e.g.: myObj.Method( Want to reformat these too, run with the -no-ignore-generated flag. Generated filesīy default, the tool will not format any files that look like they're generated. Set via the -base-formatter flag the command provided here should accept its input via The base formatter (if found), otherwise it will revert to gofmt. Custom formattersīy default, the tool will use goimports as Off by default since the quality isn't great. Logic for shortening single-line (i.e., //-prefixed) comments, but this is turned Shortening long comment lines is harder than shortening code because comments can Running the tool with the -dry-run flag will show pretty, git-style diffs. Line length settingsīy default, the tool tries to shorten lines that are longer than 100 columnsĪnd assumes that 1 tab = 4 columns. Run golines -help to seeĪll available flags and settings. Some other options are described in the sections below. Provided, then input is taken from stdin (as with gofmt).īy default, the results are printed to stdout. The paths can be either directories or individual files. If you're using golang 1.18, run: go install for older golang versions, run: go install run: golines ![]() If you need to use golines with an older version of go, install the tool from the v0.9.0įirst, install the tool. The latest version of golines requires golang 1.18 due to generics-related dependencies. More background and technical details are available in The one above, according to their preferences. We built golines to give go developers the option to automatically shorten long lines, like That very long lines are more difficult to read than their shortened alternatives. While there are different tastes when it comes to line lengths in go, we've generally found The standard golang formatting tools ( gofmt, goimports, etc.) are great, butĭeliberately don't shorten long lines instead, this Golines is a golang formatter that shortens long lines, in addition to all ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |