go 学习笔记(4) import



package main
import (
f "fmt"
)
const NAME string = "imooc"
var a string = "慕课网"
type imoocInt int
type learn struct {
}
type ilearn interface {
}
func myfun() {
f.Println(NAME)
f.Println(a)
}
func main() {
myfun()
f.Println("hi")
f.Print(a, "hello")
}
import (
f "fmt"
)
f是fmt的别名
package main
import (
. "fmt"
)
const NAME string = "imooc"
var a string = "慕课网"
type imoocInt int
type learn struct {
}
type ilearn interface {
}
func myfun() {
Println(NAME)
Println(a)
}
func main() {
myfun()
Println("hi")
Print("hello")
}
'.' 可省略包名,不建议使用
package main
import(
_ "fmt"
)
func main(){
}
只会执行fmt中init函数,不能使用fmt中函数(作用注册包引擎)
浙公网安备 33010602011771号