fix: Startup error ()

* fix: Startup error

Fixed a path error that prompted that the configuration file could not be found at startup

* Update config.go

Co-authored-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
pull/34/head
antcorp 3 years ago committed by GitHub
parent 65157ede23
commit 7c3aa7ee0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2,17 +2,15 @@ package config
import (
"io/ioutil"
"os"
"path/filepath"
"runtime"
"gopkg.in/yaml.v3"
)
var (
_, b, _, _ = runtime.Caller(0)
// Root folder of this project
Root = filepath.Join(filepath.Dir(b), "../../..")
)
var Config config
@ -156,9 +154,8 @@ type config struct {
}
func init() {
// if we cd Open-IM-Server/src/utils and run go test
// it will panic cannot find config/config.yaml
bytes, err := ioutil.ReadFile(Root + "/config/config.yaml")
path, _ := os.Getwd()
bytes, err := ioutil.ReadFile(path + "/config/config.yaml")
if err != nil {
panic(err)
}

Loading…
Cancel
Save