feat: config file
This commit is contained in:
24
internal/config/config.go
Normal file
24
internal/config/config.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"github.com/knadh/koanf"
|
||||
)
|
||||
|
||||
var (
|
||||
K = koanf.New(".")
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
API struct {
|
||||
URL string `koanf:"url"`
|
||||
Token string `koanf:"token"`
|
||||
} `koanf:"api"`
|
||||
}
|
||||
|
||||
func LoadConfig(provider koanf.Provider, parser koanf.Parser) error {
|
||||
return K.Load(provider, parser)
|
||||
}
|
||||
|
||||
func Unmarshal(o interface{}) error {
|
||||
return K.Unmarshal("", o)
|
||||
}
|
||||
Reference in New Issue
Block a user