Documentation
¶
Overview ¶
Package cache handles managing the actual installing of tools. It handles downloading and building the go modules. Tools are stored in a cache on the OS filesystem so that they can be reused by other projects.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache manages tools in an OS filesystem directory.
func New ¶
New creates a new Cache instance that uses the directory dir. Options can be provided to customize the Cache instance.
func (*Cache) FindUpdate ¶
FindUpdate checks if there is a newer version available for tool t. If no newer version is found, an empty string is returned.
func (*Cache) Install ¶
Install installs the given tool. t must have ImportPath set, otherwise an error will be returned. If t.Version is empty, then the latest version of the tool will be installed. The returned tool will have Version set to the version that was installed.
The provided context is used to terminate the install if the context becomes done before the install completes on its own.
type Go ¶
type Go interface { // Build builds pkg and outputs the binary at outPath. dir is used as the working directory // when building. pkg must be a valid import path. // Build functions like 'go build -o'. // // The provided context is used to terminate the build if the context becomes // done before the build completes on its own. Build(ctx context.Context, pkg, outPath, dir string) error // GetD downloads the source code for the module mod. dir is used as the working directory // and is expected to contain a go.mod file which will be updated with the installed module. // mod must be a valid module name, that is an import path, optionally with a version. // If no version is provided, the latest version will be downloaded. // GetD functions like 'got get -d' in module aware mode. // // The provided context is used to terminate the download if the context becomes // done before the download completes on its own. GetD(ctx context.Context, mod, dir string) error // ListU lists the details of mod and a version update if one is available. dir is used as // the working directory and is expected to contain a go.mod file with mod. // ListU functions like 'go list -m -u -json'. // // The provided context is used to terminate listing if the context becomes done // before listing completes on its own. ListU(ctx context.Context, mod, dir string) (GoModule, error) }
Go represents the core functionality provided by the go command. It allows for downloading and building of modules.
type Option ¶
type Option func(*Cache)
Option is a function that takes a Cache instance and applies a configuration to it.
func WithLogger ¶
func WithLogger(logger logrus.FieldLogger) Option
WithLogger sets a logger that should be used for writing debug messages. By default no logging is done.