MCPcopy Create free account
hub / github.com/Super-long/ChubbyGo / LoadServerConfig

Function LoadServerConfig

Config/read_server_config.go:34–52  ·  view source on GitHub ↗
(filename string, cfg *Connect.ServerConfig)

Source from the content-addressed store, hash-verified

32}
33
34func LoadServerConfig(filename string, cfg *Connect.ServerConfig) bool {
35
36 Server_file_locker.Lock()
37 data, err := io.ReadFile(filename) //read config file
38 Server_file_locker.Unlock()
39 if err != nil {
40 log.Printf("read json file error,%s\n", err.Error())
41 return false
42 }
43 // Unmarshal对于结构体偏向于精确匹配,也接收不精确匹配
44 err = json.Unmarshal(data, &cfg)
45 // 太扯了 不加双引号解不出数组
46 // fmt.Printf("DEBUG : data %s : %s : %s : %s\n",data, cfg.SnapshotFileName, cfg.RaftstateFileName,cfg.PersistenceStrategy)
47 if err != nil {
48 log.Println("unmarshal json file error")
49 return false
50 }
51 return true
52}

Callers

nothing calls this directly

Calls 1

ErrorMethod · 0.45

Tested by

no test coverage detected