MCPcopy Create free account
hub / github.com/ArchiveNetwork/wgcf-cli / readConfigFile

Function readConfigFile

src/read.go:9–42  ·  view source on GitHub ↗
(filePath string)

Source from the content-addressed store, hash-verified

7)
8
9func readConfigFile(filePath string) (string, string, error) {
10 var file *os.File
11 var err error
12 var content []byte
13 var genericResponse map[string]interface{}
14 if file, err = os.Open(filePath); err != nil {
15 panic(err)
16 }
17 defer file.Close()
18
19 if content, err = io.ReadAll(file); err != nil {
20 panic(err)
21 }
22
23 if err := json.Unmarshal(content, &genericResponse); err == nil {
24 if account, ok := genericResponse["account"].(map[string]interface{}); ok {
25 if _, ok := account["license"]; ok {
26 var ReadedFile NormalResponse
27 if err = json.Unmarshal(content, &ReadedFile); err != nil {
28 panic(err)
29 }
30 return ReadedFile.Token, ReadedFile.ID, nil
31 }
32 }
33 if _, ok := genericResponse["version"]; ok {
34 var ReadedFile TeamResponse
35 if err = json.Unmarshal(content, &ReadedFile); err != nil {
36 panic(err)
37 }
38 return ReadedFile.Token, ReadedFile.ID, nil
39 }
40 }
41 panic(nil)
42}

Callers 2

TestMainFunction · 0.85
mainFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestMainFunction · 0.68