Skip to content

heindl/go-ptimports

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-ptimports

go-ptimports is a formatter for Go code. Functionally, it is almost identical to goimports. However, it provides the following extra functionality:

  • When the -s flag is specified, code is simplified in the same manner as gofmt -s

For example, a range statement such as:

range i, _ := arr {
    _ = i
}

becomes:

range i := arr {
    _ = i
}
  • When the -r flag is specified, any non-CGo non-block imports are converted to block imports

For example:

import "go/ast"

becomes:

import (
	"go/ast"
)

Import statements of the form import "C" (and any comments associated with such import statements) are preserved.

The output of go-ptimports is compliant with goimports and gofmt.

Runing go-ptimports without any extra flags matches the behavior of goimports. Running go-ptimports with the --format-only flag is roughly equivalent to the behavior of gofmt.

About

Go formatter that formats Go files and organizes imports into sections

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 77.3%
  • Shell 22.7%