golang converts slices to string type

import (
   "encoding/json"
   "fmt"
)

var a []string
a = ["s","d","f"]
b, err := json.Marshal(a)
if err != nil {
    
    
	panic(err)
}
result := string(b)
fmt.Println(result)

The above is to convert the slice a into a string result

Guess you like

Origin blog.csdn.net/weixin_43202081/article/details/114872970