Package Mainimport ("Encoding/json"//JSON Tool "FMT")//github.com/pquerna/ffjson/ffjson//this JSON tool is much more efficient than its own JSON /and interface, exactly, type worker struct {Name string ' JSON: ' worker_name '///Convert to JSON format, key is Worker_name Sex string sal ay int32//Note that JSON does not operate on this property because Salay is lowercase}func main () {///1, array form, encoded by x: = [5]int{1, 2, 3, 4, 5} bytes, E: = JSO N.marshal (x) if E! = nil {panic (e)} fmt. Println (String (bytes))//[1,2,3,4,5]//2, for map type, json var stu = map[string]string{} stu = Make (Map[string]stri NG) stu["name"] = "Beijing" Stujson, err: = json. Marshal (stu) if err! = Nil {panic (err)} FMT. Println (String (Stujson))//{"name": "Beijing"}//3, JSON-encoded struct object wk: = worker{Name: "Xiaozhang", Sex: "Male", salay:34,} wrjson, ERR2: = json. Marshal (wk) if err2! = nil {panic (ERR2)} fmt. Println (String (Wrjson))//{"Worker_name": "Xiaozhang", "Sex": "Male"}//4, Solution to WrjsonCode var w interface{}//Declare a interface to store the decoded value JSON. Unmarshal (Wrjson, &w) fmt. PRINTF ("---JSON format decoding---->%v", W)//map[worker_name:xiaozhang Sex:male]}
==================================
package mainimport ( "crypto/md5" "fmt")//注意,md5是不逆的//md5的格式,基本上是一样的//使用时,按照下面的格式,copy就可以了。func main() { Md5Inst := md5.New() Md5Inst.Write([]byte("admin")) Result := Md5Inst.Sum([]byte("")) fmt.Printf("%x\n\n", Result)}