Documentation ¶
Index ¶
- Constants
- Variables
- func GetApolloCluster(cluster string) string
- func GetApolloNamespace(namespace string) string
- func GetApolloSecret() string
- func GetEnv(envName string) string
- func Init(userConf map[string]string)
- func IsDebug(v string) bool
- func IsDev() bool
- func IsLocal() bool
- func IsProd() bool
- func IsTest() bool
- func Parse(v interface{}, opts ...Options) error
- func ParseWithFuncs(v interface{}, funcMap map[reflect.Type]ParserFunc, opts ...Options) error
- type OnSetFn
- type Options
- type ParserFunc
Constants ¶
View Source
const ( AppEnv = "APP_ENV" AppName = "APP_NAME" AppVersion = "APP_VERSION" TraceName = "TRACE_NAME" ApolloUrl = "APOLLO_URL" ApolloAppID = "APOLLO_APPID" ApolloSecret = "APOLLO_ACCESS_KEY_SECRET" GrpcPort = "GRPC_PORT" HttpPort = "HTTP_PORT" PprofPort = "PPROF_PORT" )
Variables ¶
View Source
var ( // ErrNotAStructPtr is returned if you pass something that is not a pointer to a // Struct to Parse. ErrNotAStructPtr = errors.New("env: expected a pointer to a Struct") )
nolint: gochecknoglobals
Functions ¶
func GetApolloCluster ¶ added in v0.0.4
func GetApolloNamespace ¶ added in v0.0.4
func GetApolloSecret ¶ added in v0.0.4
func GetApolloSecret() string
func Parse ¶ added in v0.0.7
Parse parses a struct containing `env` tags and loads its values from environment variables.
func ParseWithFuncs ¶ added in v0.0.7
func ParseWithFuncs(v interface{}, funcMap map[reflect.Type]ParserFunc, opts ...Options) error
ParseWithFuncs is the same as `Parse` except it also allows the user to pass in custom parsers.
Types ¶
type Options ¶ added in v0.0.7
type Options struct { // Environment keys and values that will be accessible for the service. Environment map[string]string // TagName specifies another tagname to use rather than the default env. TagName string // RequiredIfNoDef automatically sets all env as required if they do not declare 'envDefault' RequiredIfNoDef bool // OnSet allows to run a function when a value is set OnSet OnSetFn // Prefix define a prefix for each key Prefix string // contains filtered or unexported fields }
Options for the parser.
type ParserFunc ¶ added in v0.0.7
ParserFunc defines the signature of a function that can be used within `CustomParsers`.
Click to show internal directories.
Click to hide internal directories.