Documentation
¶
Overview ¶
Package config provides a global config store that other packages can utilise for fetching/storing configuration. The config store supports both file and environment configuration.
Index ¶
Constants ¶
View Source
const ( // AppName is the application name. AppName = "Foragd" // AppID is the application name formatted for use as an ID. AppID = "app.foragd" // AppDescription is the catch-line of the application. AppDescription = "" /* 139-byte string literal not displayed */ // ConfigEnvPrefix defines the environment variable prefix for reading // server configuration from the environment. ConfigEnvPrefix = "FORAGD_" )
Variables ¶
View Source
var ( ErrLoadConfig = errors.New("error loading config") ErrInvalidConfig = errors.New("invalid config") )
View Source
var CurrentEnvironment = EnvDevelopment
CurrentEnvironment is the environment in which the app is running (i.e., production, development). Defaults to "development".
View Source
var Init = sync.OnceValue(func() error { if Version == "_UNKNOWN_" { var vcsRevision string // var vcsTime string var vcsModified bool var vcsSystem string if info, ok := debug.ReadBuildInfo(); ok { for buildInfo := range slices.Values(info.Settings) { switch buildInfo.Key { case "vcs": vcsSystem = buildInfo.Value case "vcs.revision": vcsRevision = buildInfo.Value case "vcs.modified": vcsModified = buildInfo.Value == "true" } } Version = strings.Join([]string{vcsSystem, vcsRevision}, "-") if vcsModified { Version += "-dirty" } } } if Version == "_UNKNOWN_" { return fmt.Errorf("%w: version not set correctly", ErrLoadConfig) } CurrentEnvironment = Environment(os.Getenv("FORAGD_ENVIRONMENT")) return nil })
Init ensures the application will have appropriate Version and Envrionment vars set.
View Source
var Version = "_UNKNOWN_"
Version is the application/stack version.
Functions ¶
Types ¶
type Environment ¶
type Environment string
Environment is the app running environment.
const ( // EnvDevelopment represents a development environment. EnvDevelopment Environment = "development" // EnvProduction represents a production envrionment. EnvProduction Environment = "production" )
func (Environment) String ¶ added in v0.87.0
func (e Environment) String() string
Click to show internal directories.
Click to hide internal directories.