修正格式.
Signed-off-by: chen.yang <chen.yang@yuzhen-iot.com>
This commit is contained in:
parent
b6f4c9d119
commit
d582c5f14f
|
@ -9,7 +9,6 @@
|
|||
package pkg
|
||||
|
||||
// ...
|
||||
|
||||
```
|
||||
|
||||
## 2.导入和使用包
|
||||
|
@ -55,19 +54,19 @@ import "shorturl/model"
|
|||
有时候会看到如下的方式导入包:
|
||||
|
||||
```go
|
||||
import ( . “fmt” )
|
||||
import ( . "fmt" )
|
||||
```
|
||||
|
||||
这个“\.”操作的含义就是这个包导入之后在你调用这个包的函数时,你可以省略前缀的包名,也就是前面你调用的:
|
||||
|
||||
```go
|
||||
fmt.Println(“hello world”)
|
||||
fmt.Println("hello world")
|
||||
```
|
||||
|
||||
可以省略的写成:
|
||||
|
||||
```go
|
||||
Println(“hello world”)
|
||||
Println("hello world")
|
||||
```
|
||||
|
||||
### 2.4.别名
|
||||
|
@ -75,13 +74,13 @@ Println(“hello world”)
|
|||
别名操作顾名思义可以把包命名成另一个用起来容易记忆的名字:
|
||||
|
||||
```go
|
||||
import ( f “fmt” )
|
||||
import ( f "fmt" )
|
||||
```
|
||||
|
||||
别名操作调用包函数时前缀变成了重命名的前缀,即:
|
||||
|
||||
```go
|
||||
f.Println(“hello world”)
|
||||
f.Println("hello world")
|
||||
```
|
||||
|
||||
### 2.5.“\_”操作
|
||||
|
@ -90,8 +89,8 @@ f.Println(“hello world”)
|
|||
|
||||
```go
|
||||
import (
|
||||
“database/sql”
|
||||
_ “github.com/ziutek/mymysql/godrv”
|
||||
"database/sql"
|
||||
_ "github.com/ziutek/mymysql/godrv"
|
||||
)
|
||||
```
|
||||
|
||||
|
|
Loading…
Reference in New Issue