1、当前程序的包名
package main
2、导入其他的包
import console "fmt"
3、常量的定义
const PI = 3.14
4、全局变量的声明与赋值
var name = "lxc"
5、一般类型的声明
type newType int
6、结构体的声明
type person struct {
name string
age int
}
7、接口的声明
type golang interface { }
8、由main函数作为程序入口点启动
func main() {
console.Println("hello world")
}
查看一个变量的类型的方式:
var name string = "lxc"
fmt.Printf("%T", name) //string
网友评论