File tree 2 files changed +3
-1
lines changed
2 files changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -110,6 +110,8 @@ channel通过操作符`<-`来接收和发送数据
110
110
fmt.Println(<-c)
111
111
fmt.Println(<-c)
112
112
}
113
+ //修改为1报如下的错误:
114
+ //fatal error: all goroutines are asleep - deadlock!
113
115
114
116
## Range和Close
115
117
上面这个例子中,我们需要读取两次c,这样不是很方便,Go考虑到了这一点,所以也可以通过range,像操作slice或者map一样操作缓存类型的channel,请看下面的例子
Original file line number Diff line number Diff line change 1
1
# 5.1 database/sql接口
2
- Go与PHP不同的地方是Go没有官方提供数据库驱动,而是为开发者开发数据库驱动定义了一些标准接口 ,开发者可以根据定义的接口来开发相应的数据库驱动,这样做有一个好处,只要按照标准接口开发的代码 , 以后需要迁移数据库时,不需要任何修改。那么Go都定义了哪些标准接口呢?让我们来详细的分析一下
2
+ Go与PHP不同的地方是Go官方没有提供数据库驱动,而是为开发数据库驱动定义了一些标准接口 ,开发者可以根据定义的接口来开发相应的数据库驱动,这样做有一个好处,只要是按照标准接口开发的代码 , 以后需要迁移数据库时,不需要任何修改。那么Go都定义了哪些标准接口呢?让我们来详细的分析一下
3
3
4
4
## sql.Register
5
5
这个存在于database/sql的函数是用来注册数据库驱动的,当第三方开发者开发数据库驱动时,都会实现init函数,在init里面会调用这个` Register(name string, driver driver.Driver) ` 完成本驱动的注册。
You can’t perform that action at this time.
0 commit comments