golang
已收录文章:14073篇
-
最近用go写程序时遇到一个问题——求任意类型切片的长度。 作为一个初学者,刚刚学了接口和切片,知道了每个类型都实现了一个空接口interface{},那么如果接口类型作为函数的参数,那它应489 收藏
-
源码中的 nil 是这样定义的 // nil is a predeclared identifier representing the zero value for a // pointer, channel, func, interface, map, or slice type. var nil Type // Type must be a pointer, channel, func, interface, map, or slice type 所489 收藏
-
问题内容 我用的github.com/go-sql-driver/mysql这个驱动,我像下面这样写没有报错,但是里面的数据为空或者0 type data struct { id int name string weight int } rows, _ := db.Query("select * from test where id = ?",489 收藏
-
问题内容 func test_gomaxprocs() { runtime.GOMAXPROCS(1) wg := sync.WaitGroup{} wg.Add(20) for i := 0; i < 10; i++ { go func() { fmt.Println("i:", i) defer wg.Done() }() } for i := 0;489 收藏
-
问题内容package main import ( "fmt" ) func main() { fmt.Println(f0()) // 1 fmt.Println(f1()) // 0 } func f0() (result int) { defer func() { result++ }() return 0 } func f1() (result int) { result = 0 //return语489 收藏
-
问题内容基于docker的web微服务运行的时候,映射了宿主的log目录到容器的log目录,此时我们开启了一个filebeat微服务,这个微服务的目的就是吧log目录的日志同步到elasticsearch,问题是我们如何确489 收藏