package
module
Version:
v0.5.1
Opens a new window with list of versions in this module.
Published: Jan 18, 2024
License: Apache-2.0
Opens a new window with license information.
Imports: 9
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
¶
Help configure go projects using both a configuration template yaml file and environment variables.
Usage
Import the package and load a YAML file with template data. If your current directory contains a .env
file, this will be loaded automatically.
package main
import (
"log"
"os"
"github.com/invopop/configure"
)
const configFile = "samples/config.yaml.tmpl"
// Config definition for our project
type Config struct {
S3Bucket string `json:"s3_bucket"`
}
func main() {
conf := new(Config)
if err := configure.Load(configFile, conf); err != nil {
log.Fatal("Error loading configuration file")
}
fmt.Printf("S3 Bucket is: %v\n", conf.S3Bucket)
}
Documentation
¶
Package configure makes it easier to load configuration files
from YAML documents and will handle environment variable
substitution.
Load reads in the configuration file relative to the current path. Data
is expected in YAML format with Golang template definitions.
Source Files
¶
Directories
¶
pkg
|
|
grpcconf
Package grpcconf helps configure gRPC service connections.
|
Package grpcconf helps configure gRPC service connections. |
natsconf
Package natsconf helps configure NATS connections from a JSON/YAML configuration source.
|
Package natsconf helps configure NATS connections from a JSON/YAML configuration source. |
zeroconf
Package zeroconf helps configure the zerolog package using a json configuration.
|
Package zeroconf helps configure the zerolog package using a json configuration. |
Click to show internal directories.
Click to hide internal directories.