forked from SpenserCai/sd-webui-deoldify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
48 lines (41 loc) · 896 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
* @Author: SpenserCai
* @Date: 2023-08-09 22:48:29
* @version:
* @LastEditors: SpenserCai
* @LastEditTime: 2023-08-12 21:30:23
* @Description: file content
*/
package main
import (
Global "DeoldifyBot/global"
"encoding/json"
"os"
"path/filepath"
SdClient "github.com/SpenserCai/sd-webui-go"
Core "DeoldifyBot/core"
)
func LoadConfig() error {
// 从程序运行目录下的 config.json 文件中读取配置
exePath, err := os.Executable()
if err != nil {
return err
}
exeDir := filepath.Dir(exePath)
configPath := filepath.Join(exeDir, "config.json")
file, err := os.Open(configPath)
if err != nil {
return err
}
defer file.Close()
err = json.NewDecoder(file).Decode(&Global.Config)
if err != nil {
return err
}
Global.StableClient = SdClient.NewStableDiffInterface(Global.Config.SdWebUiAddr)
return nil
}
func main() {
LoadConfig()
Core.RunBot()
}