zhangmeng
2019-12-20 e0b3d1f0183c43e4395d85b0fbcc9db775cc834c
sdk.go
@@ -1,46 +1,19 @@
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
// MsgSDK sdk msg
type MsgSDK struct {
   // protomsg.SdkMessage
   MsgData []byte
   // all sdk count
   SdkCount int
   // current sdk index
   SdkIndex int
   // current sdk result len
   SdkDataLen int
}