package here

import "github.com/markbates/pkger/here"

Index

Types

type Info

type Info struct {
	Dir        string
	ImportPath string
	Name       string
	// Imports    []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

Source Files

current.go dir.go here.go info.go info_map.go module.go parse.go path.go pkg.go

Version
v0.3.0
Published
Oct 22, 2019
Platform
js/wasm
Imports
13 packages
Last checked
7 hours ago

Tools for package owners.