confutil

package
v0.0.0-...-4e19d54 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsTestEnv

func IsTestEnv() bool

Types

type Env

type Env string
const (
	EnvTest Env = "test"
	EnvDev  Env = "dev"
	EnvStg  Env = "stg"
	EnvProd Env = "prod"
)

func CurrentEnv

func CurrentEnv() Env

type GlobalLoader

type GlobalLoader[C any] struct {
	// contains filtered or unexported fields
}

func NewGlobalLoader

func NewGlobalLoader[C any](fs_ fs.FS) *GlobalLoader[C]

func (*GlobalLoader[C]) Get

func (gl *GlobalLoader[C]) Get() *C

func (*GlobalLoader[C]) Load

func (gl *GlobalLoader[C]) Load() error

type Loader

type Loader[C any] struct {
	// contains filtered or unexported fields
}

func NewLoader

func NewLoader[C any](fs_ fs.FS) *Loader[C]

func (*Loader[C]) Load

func (l *Loader[C]) Load(env Env) (*C, error)

type YAMLTemplate

type YAMLTemplate struct{}

func NewYAMLTemplate

func NewYAMLTemplate() *YAMLTemplate

func (*YAMLTemplate) Compile

func (t *YAMLTemplate) Compile(name string, r io.Reader, w io.Writer) error

func (*YAMLTemplate) Env

func (t *YAMLTemplate) Env(key string, defaultValues ...string) string

キーで指定された環境変数を返す。このとき値が空なら、デフォルト引数リストの中から最初のゼロでない値を返す。

os.Setenv("A", "1")

a: {{ env "A" }}                 #=> a: 1
b: {{ env "B" "val" }}           #=> b: val
c: {{ env "C" (env "D") "val" }} #=> c: val

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL