gowork

package
v0.0.0-...-e71f8c3 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBug is returned when the error is probably a bug.
	ErrBug = errors.New("probably a bug")

	// ErrInvalidGowork is returned when the go.work is invalid.
	ErrInvalidGowork = errors.New("invalid go.work")

	// ErrInvalidGomod is returned when the go.mod is invalid.
	ErrInvalidGomod = errors.New("invalid go.mod")
)

Functions

This section is empty.

Types

type Environment

type Environment interface {
	Get(name string) string
}

Environment is used to get environment variables.

type FileSystem

type FileSystem interface {
	fs.FS
	// Cwd works like os.Getwd
	Cwd() (string, error)
}

FileSystem is used to read files from the file system in a testable way.

type Module

type Module struct {
	// Name is a module name.
	Name string
	// Path is a module file path.
	Path string
}

Module represents a Go module.

func Current

func Current(filesystem FileSystem, env Environment) (*Module, error)

Current returns the current Go module.

func List

func List(filesystem FileSystem, env Environment) ([]Module, error)

List returns the list of modules in the current Go workspace.

type RealSystem

type RealSystem struct{}

RealSystem is the real, live OS implementation.

func (RealSystem) Abs

func (s RealSystem) Abs(filepath string) string

func (RealSystem) Cwd

func (s RealSystem) Cwd() (string, error)

func (RealSystem) Get

func (s RealSystem) Get(name string) string

func (RealSystem) Open

func (s RealSystem) Open(name string) (fs.File, error)

Jump to

Keyboard shortcuts

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