24 lines
356 B
Go
24 lines
356 B
Go
package config
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/pelletier/go-toml/v2"
|
|
)
|
|
|
|
func LoadConfig(config interface{}) {
|
|
if err := toml.Unmarshal(readFile("config.toml"), config); err != nil {
|
|
fmt.Println(err)
|
|
config = nil
|
|
}
|
|
}
|
|
|
|
func readFile(path string) []byte {
|
|
data, err := os.ReadFile(path)
|
|
if err != nil {
|
|
return make([]byte, 0)
|
|
}
|
|
return data
|
|
}
|