#
This code groups the imports into a parenthesized, "factored" import statement.
You can also write multiple import statements, like:
import "fmt"
import "math"
But it is good style to use the factored import statement.
代码
package main
import (
"fmt"
"math"
)
func main() {
fmt.Printf("Now you have %g problems.\n", math.Sqrt(7))
}
翻译
这段代码使用import语句,在一个括号里面.
当然你也可以分开写,(类似于java的import语句一样,一行一行的import)
但是使用括号形式的import是个好的style(格式)
总结
使用import,请使用括号形式,也就是如下形式:
import (
"fmt"
"math/rand"
"time"
"mouse/rest"
)
下面这种形式不推荐(当然语法上没有任何问题,就是不推荐这种style,具体原因,我也不知道)
import "fmt"
import "math/rand"
import "time"
import "mouse/rest"
实验项目
我有一个Go的小白鼠项目,如果有需要可以clone一份.
名称 | 地址 |
---|---|
git地址 | github.com/liuxuzxx/mo… |
git的clone地址 | github.com/liuxuzxx/mo… |