Documentation ¶
Index ¶
- Constants
- Variables
- func GolangEnvForPath(path string) (Environment, Environment, error)
- func PrintEnvironment(w io.Writer, env Environment) error
- type Config
- type ConfigTransformer
- type ConfigTransformerFactory
- type ConfigTransformerFunc
- type Environment
- type EnvironmentComputer
- type EnvironmentOption
- type YAMLConfig
Constants ¶
const ConfigFileName = ".gopath"
ConfigFileName - file name containing the gilo configuration.
const (
// DefaultVersion used if version isn't set.
DefaultVersion = "development"
)
const ShimBinaryName = "gilo-shim"
ShimBinaryName name of the shim binary name
Variables ¶
var Debug = log.New(ioutil.Discard, "DEBUG ", log.LstdFlags|log.Lshortfile)
Debug logger, defaults to discard
var ErrDuplicateBinaryDirectory = errors.New("found multiple instances of the gilo bin directory within the path")
ErrDuplicateBinaryDirectory - Usually indicates an environment problem and gilo may behave unexpectedly. For example infinite loops. Gilo Attempts to bypass this behaviour by stripping all occurrances of the gilo bin directory from the path, but if other binaries are installed at that location then they may not be properly resolved within the executed environment.
var NoopTransformer = ConfigTransformerFunc(func(c Config) (Config, error) { return c, nil })
NoopTransformer - Does not make any changes to the configuration. Used for Tests.
var Version string
Version specified at build time using: `git describe --tags --long`
Functions ¶
func GolangEnvForPath ¶
func GolangEnvForPath(path string) (Environment, Environment, error)
GolangEnvForPath - Takes a path and returns the default and computed environments.
func PrintEnvironment ¶
func PrintEnvironment(w io.Writer, env Environment) error
PrintEnvironment - Prints information about the specified environment to the writer.
Types ¶
type Config ¶
type Config struct { Goroot string Gobin string Gorace string Gotooldir string GoGCCFlags string Gopaths []string }
Config - Configuration for gilo. allows specifying various golang environment variables.
func ConfigFromEnvironment ¶
func ConfigFromEnvironment(env Environment) Config
ConfigFromEnvironment - creates a config from the environment.
type ConfigTransformer ¶
ConfigTransformer - Responsible for taking a base configuration and transforming it into another configuration. A ConfigTransformer should not return any updated values in the returned configuration if an error occurs. i.e. when an error occurs the input config should be equal to the output config.
func CompositeConfigTransformer ¶
func CompositeConfigTransformer(transformers ...ConfigTransformer) ConfigTransformer
CompositeConfigTransformer - Takes a set of transformers and applies each one to the the input configuration. If any of the transformers fail, then the composite transformer fails immediately and returns the error.
func MustNewTransformers ¶
func MustNewTransformers(path string) ConfigTransformer
MustNewTransformers - Panics if the delegated invocation of NewTransformers errors.
func NewConfigTransformerFromPath ¶
func NewConfigTransformerFromPath(path string) ConfigTransformer
NewConfigTransformerFromPath - Creates a new configuration with default values from the specified path. Completely ignores the provided configuration.
func NewTransformers ¶
func NewTransformers(giloconfigpath string) (ConfigTransformer, error)
NewTransformers - Generates the set of Configuration Transformers needed based on the provided filepath to a configuration file.
type ConfigTransformerFactory ¶
type ConfigTransformerFactory struct {
util.FileResolver
}
ConfigTransformerFactory - Builds a ConfigTransformer
func (ConfigTransformerFactory) Build ¶
func (t ConfigTransformerFactory) Build(name string) (ConfigTransformer, error)
Build - Takes a path and returns either a ConfigTransformer or an error.
type ConfigTransformerFunc ¶
ConfigTransformerFunc - Allows pure functions to act as ConfigTransformers.
type Environment ¶
type Environment struct { Goroot string Gobin string Gorace string Gotooldir string GoGCCFlags string Gopaths []string Path string // Path environment variable, we update it based on the golang configuration. }
Environment - Specifies a golang environment.
func DefaultEnvironment ¶
func DefaultEnvironment(options ...EnvironmentOption) Environment
DefaultEnvironment - Loads golang default environment from environment variables.
func NewEnvironment ¶
func NewEnvironment(template Environment, options ...EnvironmentOption) Environment
NewEnvironment creates a new environment using the template and the options.
func (Environment) Gopath ¶
func (t Environment) Gopath() string
Gopath - Returns the list seperated (:) gopath.
func (Environment) MungeEnvironment ¶
func (t Environment) MungeEnvironment()
MungeEnvironment - munges the environment variables with updated values.
func (Environment) ReplaceWithGobinInPath ¶
func (t Environment) ReplaceWithGobinInPath(pattern string) Environment
ReplaceWithGobinInPath - Replaces the first occurrance of the given string with the Environment's Gobin value.
func (Environment) StripFromPath ¶
func (t Environment) StripFromPath(subpath string) Environment
StripFromPath - Updates the environment's Path by stripping the specified subpath from the path.
func (Environment) UpdateFromConfig ¶
func (t Environment) UpdateFromConfig(config Config) Environment
UpdateFromConfig - Updates the environment using the specified configuration.
type EnvironmentComputer ¶
type EnvironmentComputer struct { // DefaultEnv - the default golang environment, used as a base for // the computed golang environment. DefaultEnv Environment // Transformer - Applies transformations to the configuration. Transformer ConfigTransformer // GiloBinary - Returns the directory path where the gilo binary // is located, used to strip the binary from the environments path. // allowing gilo to act as a shim for various commands. GiloBinary util.BinaryResolver }
EnvironmentComputer - Computes the default and configured golang environments.
func (EnvironmentComputer) Compute ¶
func (t EnvironmentComputer) Compute() (Environment, Environment, error)
Compute - Computes the default golang environment and the updated golang environment based on the provided resolver.
type EnvironmentOption ¶
type EnvironmentOption func(*Environment)
EnvironmentOption specifies an option for the environment
func EnvironmentOptionGopath ¶
func EnvironmentOptionGopath(paths ...string) EnvironmentOption
EnvironmentOptionGopath sets the gopaths for the environment
type YAMLConfig ¶
YAMLConfig - yaml based configuration.