From 2b21fd03ce861b8dbd441f57c80b818301fe41ff Mon Sep 17 00:00:00 2001 From: zhangmeng <775834166@qq.com> Date: 星期四, 19 十二月 2019 11:17:50 +0800 Subject: [PATCH] add read config --- proc.go | 37 +++++++++++++++++++++++++++++++++++++ 1 files changed, 37 insertions(+), 0 deletions(-) diff --git a/proc.go b/proc.go index a6a08ed..b9bc221 100644 --- a/proc.go +++ b/proc.go @@ -1,7 +1,44 @@ 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"` +} + +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 +const EnvNoValue = "env-no-value" + +func readEnv(file string) string { + c, err := readConfig(file) + if err != nil { + return EnvNoValue + } + return c.Env +} -- Gitblit v1.8.0