. | . | . | . | . |
---|---|---|---|---|
break | default | func | interface | select |
case | defer | go | map | struct |
chan | else | goto | package | switch |
const | fallthrough | if | range | type |
continue | for | import | return | var |
//当前程序的包名
package main
//导入其他的包
import "fmt"
/*
由main函数作为程序入口点的启动
*/
func main() {
fmt.Println("Hello world!")
}
//导入其他的包
import "fmt"
//导入其他的包
import (
"fmt"
"math"
)
const PI = 3.1415926
var a string = "abc"
//一般结构声明
type newType int
//结构的声明
type gopher struct{}
//接口的声明
type golang interface{}
//接口型函数的声明
type MatchFunction func(rune, rune) bool
func main() {
}
<PackageName>.<FuncName>
来对包中的函数进行调用fmt.Println("Hello world!")
package main
import (
fff "fmt"
)
const PI = 3.1415926
var a string = "abc"
func main() {
fff.Println(PI, a)
}
//调用第三方包的参数或函数,可以看到首字母都是大写的
fmt.Println("Hello world!")