基础转换

string -> int

int,err := strconv.Atoi(string)

string -> int64

int64,err := strconv.ParseInt(string,10,64)

int -> string

string := strconv.Itoa(int)

int64 -> string

string:=strconv.FormatInt(int64,10)

string -> map

dict := make(map[string]interface{})
err := json.Unmarshal([]byte(string),&dict)

map -> string

dict := map[string]interface{"name":"jeking"}
string :=json.Marshal(dict)

bytes -> string

string := string(bytes) //byte[]

string -> bytes

bytes := []byte(string)

你可能感兴趣的:(基础转换)