1.GO语言的特色
先说一下go的特色:
1.没有继承多态的OO
2.强一致类型
3.interfance不需要显示声明(Duck Typing)
4.没有异常处理(Error is value)
5.基于首字母的可访问特性(首字母大小写)
6.不用的import或者变量引起编译错误
7.完整而卓越的标准包
2.Hello World
学习任何一门编程语言都要从Hello World 开始:
package main
import "fmt"
func main() {
fmt.Println("Hello World")
}
3.Go常用功能的快捷键
代码格式化:
Ctrl/Alt + T:将代码包在一个块内(例如 if /else)
Ctrl/Alt + L:格式化代码
Ctrl + /:单行代码注释
Ctrl/Shift + /:多行代码注释
Ctrl + +/-:可以将当前方法进行展开或者折叠
查找和定位
Ctrl + R:单行代码注释
Ctrl + F:单行代码注释
Ctrl/Shift + F:单行代码注释
Ctrl + G:单行代码注释
4.Go程序的组成结构
//当前程序的包名
package main
//导入其他包
import "fmt"
//常量定义
const PI=3.14
//全局变量的声明和赋值
var name = "GOGOGO"
//一般类型声明
type newType int
//结构的声明
type GOModel struct{}
//结构的声明
type GoInterface interface{}
//有main函数作为程序入口点启动
func main() {
fmt.Println("Hello World")
}