Skip to content

gfx-labs/gun

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gun

gun is a preconfigured configuration for aconfig https://github.com/cristalhq/aconfig

Usage

package main

import (
	"fmt"

	"github.com/gfx-labs/gun"
)

var Config struct {
	Host      string `yaml:"host" env:"HOST" json:"host" default:"localhost"`
	Port      int    `yaml:"port" env:"PORT" json:"port" default:"8080"`
	DbUrl     string `yaml:"db_url" env:"DB_URL" json:"db_url"`
	ManyItems []string
}

func init() {
	gun.Load(&Config)
}

func main() {
	fmt.Println(Config.Host, Config.Port)
}

With a prefix:

gun.LoadPrefix(&Config, "MYAPP")
// reads env vars like MYAPP_HOST, MYAPP_PORT, etc.
// reads config files named myapp.yml, myapp.yaml, myapp.json

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages