config

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2017 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GlobalConfig = loadConfigFile("config.json")

GlobalConfig - The global configuration read from config.json

View Source
var InMemory = false

InMemory - When true the config will not write to the disk. This is used for testing.

View Source
var LocalConfig = loadConfigFile("config.local.json")

LocalConfig - The local configuration read from config.local.json

View Source
var ProjectPath = "."

The path to the project root

View Source
var TempConfig = loadDefaultConfig()

TempConfig - A temporary config object that persists only for the current session.

Functions

func ExpandString added in v0.1.2

func ExpandString(str string) string

ExpandString - Given a string with a variable inside it. The string will be expanded and the variable placeholders replaced with variables from either config. Priority goes to the local config.

func GetSetting added in v0.3.0

func GetSetting(str string) string

GetSetting - Returns the value of a variable from either config. Priority goes to the local config.

func GetVariable added in v0.1.2

func GetVariable(str string) string

GetVariable - Returns the value of a variable from either config. Priority goes to the local config.

func VariableExists added in v0.1.2

func VariableExists(str string) bool

VariableExists - Checks if a variable exists in either config.

Types

type Config

type Config struct {
	Filename string
	// contains filtered or unexported fields
}

Config - The config object is used to store the application configuration. The package attempts instantiate two configs one for the local config and one for the global config.

func LoadConfig

func LoadConfig(bytes []byte) *Config

Loads a config from a byte array.

func (*Config) ExpandString added in v0.1.2

func (c *Config) ExpandString(str string) string

ExpandString - Given a string with a variable inside it. The string will be expanded and the variable placeholders replaced with variables from the config.

func (*Config) GetSetting

func (c *Config) GetSetting(name string) string

GetSetting - Returns a setting as a string from the path specified in the config.

func (*Config) GetVariable

func (c *Config) GetVariable(path string) string

GetVariable returns a saved variable from the config.

func (*Config) SetVariable

func (c *Config) SetVariable(path, value string)

SetVariable - sets a variable in the config.

func (*Config) SettingExists added in v0.3.0

func (c *Config) SettingExists(name string) bool

SettingExists - returns true if a setting is specified in the config.

func (*Config) String

func (c *Config) String() string

String - returns the config JSON as a string.

func (*Config) VariableExists

func (c *Config) VariableExists(path string) bool

VariableExists - Checks to see if a variable exists at the path specified.

func (*Config) Write

func (c *Config) Write()

Write - writes the config to the disk. Uses the path specified in the Filename property.

Jump to

Keyboard shortcuts

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