go-project-template/config/config.go

35 lines
419 B
Go
Raw Normal View History

2024-05-05 22:10:32 +00:00
package config
import (
"encoding/json"
"os"
"github.com/sirupsen/logrus"
)
type Config struct {
Database string
HTTPBind string
}
var C = Config{
HTTPBind: ":8080",
}
func Load() error {
logrus.Info("loading config file")
f, err := os.Open("go-project-template.json")
if err != nil {
return err
}
defer f.Close()
err = json.NewDecoder(f).Decode(&C)
if err != nil {
return err
}
return nil
}