Documentation ¶
Overview ¶
Package gomod includes methods and structures to resolve relative path based on where the nearest go.mod is.
Index ¶
- func DirectCallerFunctionName() string
- func DirectCallerFunctionNameWithPackageName() string
- func DirectCallerPackageE() (s string, err error)
- func DirectCallerPackagePanic() string
- func DirectCallerPackagePath() string
- func Make(packageLines []string) (string, error)
- type Workspace
- func (ws *Workspace) BaseExpander() *expand.BaseExpander
- func (ws *Workspace) Expand(p string) string
- func (ws *Workspace) ExpandFilepath(path string) string
- func (ws *Workspace) ExpandPackage(p string) (s string, err error)
- func (ws *Workspace) GomodPathDirectory() string
- func (ws *Workspace) IsExpandable(path string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DirectCallerFunctionName ¶
func DirectCallerFunctionName() string
DirectCallerFunctionName determines the function name of the caller and returns it.
func DirectCallerFunctionNameWithPackageName ¶
func DirectCallerFunctionNameWithPackageName() string
DirectCallerFunctionNameWithPackageName returns the caller pkg.function name.
func DirectCallerPackageE ¶
DirectCallerPackageE is same as DirectCallerPackagePanic but returns an error instead of panicing once an error occurs.
func DirectCallerPackagePanic ¶
func DirectCallerPackagePanic() string
DirectCallerPackagePanic returns the package name the working directory currently points to. The function panics if working directory is not inside a workspace.
func DirectCallerPackagePath ¶
func DirectCallerPackagePath() string
DirectCallerPackagePath determines the path to the directory the caller function resides in and returns it.
Types ¶
type Workspace ¶
Workspace holds the path to the go.mod file and the module namespace.
func GetWorkspace ¶
GetWorkspace returns the workspace fromPath is part of.
func GetWorkspaceFromWD ¶
GetWorkspaceFromWD returns the workspace from the working directory.
func (*Workspace) BaseExpander ¶ added in v0.2.17
func (ws *Workspace) BaseExpander() *expand.BaseExpander
BaseExpander uses the stored path to create a BaseExpander.
func (*Workspace) Expand ¶ added in v0.2.13
Expand expands paths with leading //-prefix with the folder the nearest go.mod resides in.
func (*Workspace) ExpandFilepath ¶ added in v0.2.13
ExpandFilepath expands paths with leading //-prefix with the folder the nearest go.mod resides in.
func (*Workspace) ExpandPackage ¶
ExpandPackage expands the partial package path and expands it with the path located in the go.mod file.
func (*Workspace) GomodPathDirectory ¶
GomodPathDirectory returns the directory where the nearest go.mod resides..
func (*Workspace) IsExpandable ¶
IsExpandable checks whether expanding the given path with the given Workspace would result in an error.