first commit
This commit is contained in:
21
config/config.go
Normal file
21
config/config.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/pelletier/go-toml/v2"
|
||||
)
|
||||
|
||||
func LoadConfig(config interface{}) {
|
||||
if err := toml.Unmarshal(readFile("config.toml"), config); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func readFile(path string) []byte {
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return data
|
||||
}
|
||||
Reference in New Issue
Block a user