Skip to content

yasushi-saito/go-imports

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-imports

Emacs package for adding imports.

Setup

Add something like below to ~/.emacs:

(add-hook 'go-mode-hook
          #'(lambda()
              (require 'go-imports)
	          (define-key go-mode-map "\C-cI" 'go-imports-insert-import)
	          (define-key go-mode-map "\C-cR" go-imports-reload-packages-list)))

Using go-imports

Say you have github.com/stretchr/testify/require in your GOPATH, and you want to use this package in your go file. Invoking

(go-imports-insert-import "require")

will insert the import line

import (
  "github.com/stretchr/testify/require"
)

in the file. If invoked interactively, it will insert an import for the symbol at point.

The mappings from the package name (e.g., "require") to thus package path (e.g., "github.com/stretchr/testify/require") is discovered by scanning all the *.go files under GOROOT and GOPATH when the go-imports-insert-import is first called.

Calling go-imports-reload-packages-list will reload the package-name mappings.

About

Emacs package for adding imports.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published