Version: v0.19.0 Latest Latest

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

Go to latest
Published: Mar 20, 2018 License: MIT Imports: 12 Imported by: 0



For large projects, it may be useful to generate an index of package names for commonly used packages. The index of names can be added to each generated file using File.ImportNames. The gennames command is used internally to generate the list of standard library package names.

Usage of gennames:
  -filter string
    	Regex to filter paths (operates on full path including vendor directory) (default ".*")
  -name string
    	Name of the variable to define (default "PackageNames")
    	Exclude packages in vendor directories
  -output string
    	Output filename to write (default "./package-names.go")
  -package string
    	Package name in generated file (default "main")
  -path string
    	Path to pass to go list command (default "all")
    	Use standard library packages

Supply a path to pass to the go list command. You may use the wildcard /... to recursively return packages, but it's worth remembering that vendored packages are not returned by this method unless the path itself is a vendored path. Use all to return all packages in your GOPATH (including vendored packages), however remember this may take some time for a large GOPATH.


Supply a regex filter to limit the packages that are returned by the go list command. The filter operates on the full vendored package path (e.g., however the package path added to the index is unvendored (e.g.

gennames -filter "foo|bar"

Create a file named package-names.go with package main listing the names of all packages with paths containing foo or bar.

gennames -output "foo/names.go" -package "foo" -path ""

Create a file named foo/names.go with package foo listing the names of all packages that are vendored inside


The Go Gopher

There is no documentation for this package.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL