- Secure config loading.
- Support AWS SecretsManager.
- Easy JSON unmarshaling into a struct.
package main
import (
"context"
"github.com/gofor-little/cfg"
)
type Config struct {
SomeStringValue string `json:"someStringValue"`
SomeIntValue int `json:"someIntValue"`
}
func main() {
// Initialize the cfg package.
if err := cfg.Initialize(context.Background(), "AWS_PROFILE", "AWS_REGION"); err != nil {
panic(err)
}
// Load and parse the config data into the passed Config struct.
config := &Config{}
if err := cfg.Load(context.Background(), "AWS_SECRET_ARN", config); err != nil {
panic(err)
}
}
Ensure the following environment variables are set, usually with a .env file.
-
AWS_PROFILE
(an AWS CLI profile name) -
AWS_REGION
(a valid AWS region)
Run go test -v ./...
in the root directory.