Skip to content
Add, remove, or replace imports in Go files
Go
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin Use modules, fix linter Feb 22, 2019
.codecov.yml Update lint scripts Nov 25, 2018
.editorconfig
.gitattributes Update lint scripts Nov 25, 2018
.gitignore Update lint scripts Nov 25, 2018
.ignore Update lint scripts Nov 25, 2018
.travis.yml Update lint scripts Nov 25, 2018
LICENSE Genesis Oct 30, 2017
README.markdown Small README tweak Mar 17, 2018
go.mod Update dependencies Aug 9, 2019
go.sum Update dependencies Aug 9, 2019
goimport.go No need to add newlines after import block Aug 11, 2019
goimport_test.go Add a few more test cases Mar 16, 2018

README.markdown

This project is considered stable Build Status codecov

goimport is a tool to add, remove, or replace imports in Go files.

Install it with go get arp242.net/goimport.

Example usage:

# Add errors package.
$ goimport -add errors foo.go

# Remove errors package.
$ goimport -rm errors foo.go

# Add errors package aliased as "errs"
$ goimport -add errors:errs foo.go

# Either add an import or replace existing errors with
# github.com/pkg/errors.
$ goimport -replace github.com/pkg/errors foo.go

# Try to "go get" package if it's not found.
$ goimport -get -add github.com/pkg/errors foo.go

# Print out only the import block as JSON (useful for editor integrations).
$ goimport -json -add github.com/pkg/errors foo.go

See goimport -h for the full help.

You can’t perform that action at this time.