golang
已收录文章:13811篇
-
字符串拼接在 golang 里面其实有很多种实现。 实现方式 直接使用运算符 func BenchmarkAddStringWithOperator(b *testing.B) { hello := "hello" world := "world" for i := 0; i &465 收藏
-
问题内容 redis连接池的疑问,代码如下 package utils import ( red "github.com/gomodule/redigo/redis" "time" "fmt" ) type Redis struct { pool *red.Pool } var redis *Redis func initRedis() { redis = new(Redis) re437 收藏
-
问题内容这两个函数都会在出错的时候打印错误信息并退出程序,它们的区别在哪?正确答案panic 可以 recover ,log.Fatal 不能 recover。323 收藏
-
背景 相信有一部分人喜爱 GO 的初衷大概是:跨平台静态编译,如果在没用通过 CGO 引用其他库的话,一般编译出来的可执行二进制文件部署起来非常方便,但人们在实际中发现,使用 Go 语言开362 收藏
-
uintptr uintptr 的定义在 builtin 包下,定义如下: // uintptr is an integer type that is large enough to hold the bit pattern of // any pointer. type uintptr uintptr 参照注释我们知道: uintptr 是一个整数类型(这个非常重408 收藏
-
问题内容 1.协程对应操作系统里面的什么 2.golang是如何实现的 正确答案goroutine是Go语言运行库的功能,不是操作系统提供的功能,goroutine不是用线程实现的。goroutine就是一段代码,一个函数入口251 收藏