cfmt

command module
v0.0.0-...-0900645 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 23, 2018 License: MIT Imports: 17 Imported by: 0

README

cfmt

cfmt is a tool to wrap Go comments over a certain length to a new line.

Installation

go get -u github.com/alexkohler/cfmt

Note: cfmt requires gofmt.

Usage

Similar to other Go static anaylsis tools (such as golint, go vet), cfmt can be invoked with one or more filenames, directories, or packages named by its import path. cfmt also supports the ... wildcard.

cfmt [flags] files/directories/packages
Flags
  • -m - Maximum comment length before cfmt should insert a line break. (Default 80)
  • -w - Writes changes to file. By default, cfmt will only print the changes it will make, but will not modify the input files.

Examples

cfmt will wrap to a new line or join an existing line as appropriate. See the following before/afters of running cfmt -m=100:

Before

// I am a long comment that is over 100 characters long. I should probably wrap to a new line.

After

// I am a long comment that is over 100 characters long. I should probably wrap
// to a new line.

Before

// I am a long comment that is over 100 characters long. I should probably wrap below to the
// rest of the comment.

After

// I am a long comment that is over 100 characters long. I should probably wrap
// below to the rest of the comment.

Before

//I am a long comment that starts without a space and is over 100 characters long. When I wrap, I should still start without a space

After

//I am a long comment that starts without a space and is over 100 characters
//long. When I wrap, I should still start without a space

cfmt ignores block (/* */) comments and "grouped" comments over a length of 10 (i.e. 10+ consecutive lines starting with //).

Contributing

Pull requests welcome!

Other static analysis tools

If you've enjoyed cfmt, take a look at my other static anaylsis tools!

  • nakedret - Finds naked returns.
  • unimport - Finds unnecessary import aliases.
  • prealloc - Finds slice declarations that could potentially be preallocated.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL