config

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 23, 2025 License: MIT Imports: 8 Imported by: 1

README ¶

go-config

tag Go Version GoDoc Build Status Go report Coverage Contributors License

🚀 Install

go get github.com/cyg-pd/go-config@v1

This library is v1 and follows SemVer strictly.

No breaking changes will be made to exported APIs before v2.0.0.

This library has no dependencies outside the Go standard library.

💡 Usage

You can import go-config using:

package main

import (
	"log/slog"

	"github.com/cyg-pd/go-config"
)

// prepare environment variable
// $ export VIPER_ENV_PREFIX=abc
// $ export ABC_DB_DEFAULT_DSN=123.123.123.123

func main() {
	config.Parse()

	dsn := config.GetString("db.default.dsn")
	slog.Info(dsn) // 123.123.123.123
}

Documentation ¶

Index ¶

Constants ¶

This section is empty.

Variables ¶

This section is empty.

Functions ¶

func Get ¶

func Get(key string) any

func GetBool ¶

func GetBool(key string) bool

func GetDuration ¶

func GetDuration(key string) time.Duration

func GetFloat64 ¶

func GetFloat64(key string) float64

func GetInt ¶

func GetInt(key string) int

func GetInt32 ¶

func GetInt32(key string) int32

func GetInt64 ¶

func GetInt64(key string) int64

func GetIntSlice ¶

func GetIntSlice(key string) []int

func GetSizeInBytes ¶

func GetSizeInBytes(key string) uint

func GetString ¶

func GetString(key string) string

func GetStringMap ¶

func GetStringMap(key string) map[string]any

func GetStringMapString ¶

func GetStringMapString(key string) map[string]string

func GetStringMapStringSlice ¶

func GetStringMapStringSlice(key string) map[string][]string

func GetStringSlice ¶

func GetStringSlice(key string) []string

func GetTime ¶

func GetTime(key string) time.Time

func GetUint ¶

func GetUint(key string) uint

func GetUint16 ¶

func GetUint16(key string) uint16

func GetUint32 ¶

func GetUint32(key string) uint32

func GetUint64 ¶

func GetUint64(key string) uint64

func GetUint8 ¶

func GetUint8(key string) uint8

func Parse ¶

func Parse()

func Reset ¶

func Reset()

func Set ¶

func Set(key string, value any)

func SetDefault ¶

func SetDefault(key string, value any)

func Unmarshal ¶

func Unmarshal(rawVal any, opts ...viper.DecoderConfigOption) error

func UnmarshalExact ¶

func UnmarshalExact(rawVal any, opts ...viper.DecoderConfigOption) error

func UnmarshalKey ¶

func UnmarshalKey(key string, rawVal any, opts ...viper.DecoderConfigOption) error

Types ¶

type Config ¶

type Config struct{ *viper.Viper }

func Default ¶

func Default() *Config

Jump to

Keyboard shortcuts

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