reid from https://github.com/michuanhaohao/reid-strong-baseline
zhangmeng
2020-01-15 400044583627cc72a1a3071f1a389e18953cbba0
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
package common
 
import (
    "encoding/json"
    "fmt"
    "io/ioutil"
    "strconv"
)
 
// SubConfig sub
type SubConfig struct {
    SoFile string            `json:"so_file_path"`
    Env    string            `json:"runtime"`
    Param  map[string]string `json:"param"`
}
 
// SdkConfig sdk
type SdkConfig struct {
    SoFile string            `json:"so_file_path"`
    Env    string            `json:"runtime"`
    Param  map[string]string `json:"param"`
    Sub    *SubConfig        `json:"sub"`
}
 
// ReadConfig conf
func ReadConfig(file string) (SdkConfig, error) {
    data, err := ioutil.ReadFile(file)
    if err != nil {
        return SdkConfig{}, fmt.Errorf("READ SDK CONFIG FILE %s ERROR", file)
    }
 
    //读取的数据为json格式,需要进行解码
    var v SdkConfig
    err = json.Unmarshal(data, &v)
 
    return v, err
}
 
// Atoi atoi
func Atoi(s string) int {
    i, _ := strconv.Atoi(s)
    return i
}