防止绝对路径被编译进二进制文件
This commit is contained in:
		@@ -9,12 +9,13 @@ import (
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	_, b, _, _ = runtime.Caller(0)
 | 
			
		||||
	Root       = filepath.Join(filepath.Dir(b), "..")
 | 
			
		||||
	Viper      *viper.Viper
 | 
			
		||||
	Root  string
 | 
			
		||||
	Viper *viper.Viper
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func init() {
 | 
			
		||||
	_, b, _, _ := runtime.Caller(0)
 | 
			
		||||
	Root = filepath.Join(filepath.Dir(b), "..")
 | 
			
		||||
	config_file := filepath.Join(Root, "data", "config.yaml")
 | 
			
		||||
	viper.SetConfigFile(config_file)
 | 
			
		||||
	if err := viper.ReadInConfig(); err != nil {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user