将字符串转换为字符串

please say. Why string "\xF0\x9F\x98\x81" in the code don't equally "\xF0\x9F\x98\x81" from arguments command line?

func main() {

    text1 := "\xF0\x9F\x98\x81"
    text2 := os.Args[1]
}

Length string "text1" = 4, "text2" = 16 if len(text1). How i can convert "text2" to "text1"?

There is indeed a standard package and a function for this. strconv.Unquote

Unquote interprets s as a single-quoted, double-quoted, or backquoted Go string literal, returning the string value that s quotes. (If s is single-quoted, it would be a Go character literal; Unquote returns the corresponding one-character string.)

Note that you need to quote the input stirng. In your code, it should be:

text2 := strconv.Unquote(`"`+os.Args[1]+`"`)

Playground example: https://play.golang.org/p/u2yU3VQHhXO