code_go

1. 了解 打印格式,%q

%q 打印字符串,不会转义,打印原始内容,字符串的双引号也会打印

$ cat 1.go 
package main
import "fmt"

func main() {
    var str string = "hello\n"
    fmt.Printf("%q %s", str, str)
}
$ go run 1.go 
"hello\n" hello
$ 

 2. go语言函数中有匿名函数,需要多理解。个人认为是在函数中可以直接定义函数,然后使用

posted @ 2024-07-21 13:38  靖意风  Views(3)  Comments(0Edit  收藏  举报