here

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2019 License: MIT Imports: 13 Imported by: 19

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Info

type Info struct {
	Dir        string
	ImportPath string
	Name       string
	Module     Module
}

Info represents details about the directory/package

func Cache

func Cache(p string, fn func(string) (Info, error)) (Info, error)

func Current

func Current() (Info, error)

func Dir

func Dir(p string) (Info, error)

Dir attempts to gather info for the requested directory.

func Package

func Package(p string) (Info, error)

Package attempts to gather info for the requested package.

From the `go help list` docs:

The -find flag causes list to identify the named packages but not
resolve their dependencies: the Imports and Deps lists will be empty.

A workaround for this issue is to use the `Dir` field in the returned `Info` value and pass it to the `Dir(string) (Info, error)` function to return the complete data.

func (Info) FilePath

func (i Info) FilePath(paths ...string) string

func (Info) IsZero

func (i Info) IsZero() bool

IsZero checks if the type has been filled with rich chocolately data goodness

func (Info) MarshalJSON

func (fi Info) MarshalJSON() ([]byte, error)

func (Info) Mods

func (i Info) Mods() bool

Mods returns whether Go modules are used in this directory/package.

func (Info) ModuleName

func (i Info) ModuleName() string

ModuleName returns the name of the current module, or if not using modules, the current package. These *might* not match.

func (Info) Open

func (i Info) Open(p string) (*os.File, error)

func (Info) Parse

func (i Info) Parse(p string) (Path, error)

func (Info) String

func (i Info) String() string

type Module

type Module struct {
	Path      string
	Main      bool
	Dir       string
	GoMod     string
	GoVersion string
}

func (Module) IsZero

func (i Module) IsZero() bool

func (Module) MarshalJSON

func (m Module) MarshalJSON() ([]byte, error)

func (Module) String

func (i Module) String() string

type Path

type Path struct {
	Pkg  string `json:"pkg"`
	Name string `json:"name"`
}

func (Path) String

func (p Path) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL