struct
type Response struct {
DMErr int `json:"dm_error"`
ErrorMsg string `json:"error_msg"`
Response string `json:"response"`
}
color
fmt.Printf("%c[0;40;33m", 0x1B)
...
fmt.Printf("%c[0m", 0x1B)
connect number
body, _ := ioutil.ReadAll(request.Body)
connect_num := crc32.ChecksumIEEE([]byte(string(body) + time.Now().String()))
json <–> struct
body, _ := ioutil.ReadAll(request.Body)
var getBody []GetBody
if err := json.Unmarshal(body, &getBody); err != nil {
log.Errorf("<%d> transcode get, body Unmarshal error:%v", connect_num, err)
return
}
responseStr, _ := json.Marshal(resData)
string(responseStr)
replace
srp := strings.NewReplacer("{liveid}", liveinfo.Id)
urlStr = srp.Replace(urlStr)
string to int
uid, err := strconv.ParseUint(uidStr, 10, 64)
if err != nil {
log.Info("uid ParseUint error, err:", err)
}
strconv.Itoa(policy_int)
strconv.Atoi(policy_str)
other
ids_str = strings.Join(ids_arr_str, ",")
version_arr := strings.Split(version_str, ".")
lock
type UserRightST struct {
Policy map[int]PolicyST
PolicyMutex sync.RWMutex
}
var UserRight UserRightST
UserRight.PolicyMutex.Lock()
UserRight.Policy = policyConfig.Policy
UserRight.PolicyMutex.Unlock()