gopkgs: github.com/haya14busa/gopkgs Index | Files | Directories

package gopkgs

import "github.com/haya14busa/gopkgs"

Index

Package Files

gopkgs.go

func Packages Uses

func Packages(opt *Option) []*Pkg

Packages returns all importable Go packages. Packages uses [golang.org/x/tools/cmd/goimports](https://godoc.org/golang.org/x/tools/cmd/goimports) implementation internally, so it's fast. e.g. it cares .goimportsignore

type Option Uses

type Option struct {
    // Fill package name in Pkg struct if it's true. Note that it needs to parse
    // package directory to get package name and it takes some costs.
    IncludeName bool
}

func DefaultOption Uses

func DefaultOption() *Option

type Pkg Uses

type Pkg struct {
    Dir             string // absolute file path to Pkg directory ("/usr/lib/go/src/net/http")
    ImportPath      string // full Pkg import path ("net/http", "foo/bar/vendor/a/b")
    ImportPathShort string // vendorless import path ("net/http", "a/b")

    // It can be empty. It's filled only when Option.IncludeName is true.
    Name string // package name ("http")
}

Pkg represents exported go packages. It's based on x/tools/imports.Pkg.

Directories

PathSynopsis
x/tools/imports

Package gopkgs imports 6 packages (graph). Updated 2017-10-03. Refresh now. Tools for package owners.