gomod

package
v0.2.11 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2020 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) ExpandPackage

func (ws *Workspace) ExpandPackage(path 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) ExpandPath

func (ws *Workspace) ExpandPath(path string) (s string, err error)

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

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