| | |
| | | package sdkstruct |
| | | |
| | | import ( |
| | | "encoding/json" |
| | | "fmt" |
| | | "io/ioutil" |
| | | ) |
| | | |
| | | // SDKInfo db |
| | | type SDKInfo struct { |
| | | IpcID string |
| | | SdkType string |
| | | } |
| | | |
| | | // SdkConfig sdk |
| | | type SdkConfig struct { |
| | | SoFile string `json:"so_file_path"` |
| | | Env string `json:"runtime"` |
| | | Param map[string]string `json:"param"` |
| | | } |
| | | |
| | | // ReadConfig config json |
| | | 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 |
| | | } |
| | | |
| | | // EnvNoValue env no |
| | | const EnvNoValue = "env-no-value" |
| | | |
| | | // ReadEnv env |
| | | func ReadEnv(file string) string { |
| | | c, err := ReadConfig(file) |
| | | if err != nil { |
| | | return EnvNoValue |
| | | } |
| | | return c.Env |
| | | } |