gomod

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package gomod includes methods and structures to resolve relative path based on where the nearest go.mod is.

Index

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

func DirectCallerPackageE() (s string, err error)

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.

func Make

func Make(packageLines []string) (string, error)

Make constructs a go.mod file containing the given packages.

Types

type Workspace

type Workspace struct {
	GomodPath string
	Module    string
}

Workspace holds the path to the go.mod file and the module namespace.

func GetWorkspace

func GetWorkspace(fromPath string) (ws Workspace, err error)

GetWorkspace returns the workspace fromPath is part of.

func GetWorkspaceFromWD

func GetWorkspaceFromWD() (Workspace, error)

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

func (ws *Workspace) Expand(p string) string

Expand expands paths with leading //-prefix with the folder the nearest go.mod resides in.

func (*Workspace) ExpandFilepath added in v0.2.13

func (ws *Workspace) ExpandFilepath(path string) string

ExpandFilepath expands paths with leading //-prefix with the folder the nearest go.mod resides in.

func (*Workspace) ExpandPackage

func (ws *Workspace) ExpandPackage(p string) (s string, err error)

ExpandPackage expands the partial package path and expands it with the path located in the go.mod file.

func (*Workspace) GomodPathDirectory

func (ws *Workspace) GomodPathDirectory() string

GomodPathDirectory returns the directory where the nearest go.mod resides..

func (*Workspace) IsExpandable

func (ws *Workspace) IsExpandable(path string) error

IsExpandable checks whether expanding the given path with the given Workspace would result in an error.

Directories

Path Synopsis
Package gomodtest includes helpers for accessing files and packages inside the current Go Module.
Package gomodtest includes helpers for accessing files and packages inside the current Go Module.

Jump to

Keyboard shortcuts

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