# BeiFengGoProj **Repository Path**: ai-word/BeiFengGoProj ## Basic Information - **Project Name**: BeiFengGoProj - **Description**: Go语言学习笔记 - **Primary Language**: Go - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2018-11-08 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # BeiFengGoProj #### Description Go语言学习笔记 # Day1-20180917 ### golang环境搭建 1. 安装go工具包。 2. 设置GOROOT环境变量。 3. 设置GOPATH和GOBIN环境变量。 ![image](http://note.youdao.com/yws/res/766/BCA62BB1CB4D4051BAD13D1DDFD13517) 4. 查看环境变量 ![image](http://note.youdao.com/yws/res/771/CE416FF0CEE74BF4890F2A021ADF5AB7) ### Demo ![image](http://note.youdao.com/yws/res/774/248F3A7D98554F26B06D6C9621F1CB21) 1. 编译 ![image](http://note.youdao.com/yws/res/779/40703A49666D4119B568901DBCB9C794) 2. 运行 ![image](http://note.youdao.com/yws/res/783/AB8262A193CF4F19A35D35E841B34941) --- # Day2-20180918 #### 变量赋值及方法定义 ```go func main(){ //交换变量 //方法一: var a,b int a = 1 b = 2 temp := a a = b b = temp fmt.Printf("a->%d,b->%d\n",a,b) //方法二: c := 3 d := 4 c,d = d,c fmt.Printf("c->%d,d->%d\n",c,d) //方法返回 a ,b,c = test() fmt.Printf("a->%d,b->%d,c->%d\n",a,b,c) } func test()(a,b,c int){ return 1,2,3 } ``` #### 常量定义 ==常量被定义后,不能被修改,否则编译会报错== ```go //常量定义,常量不能被修改 const( a = 1 b = 3 ) func main() { //a = 1 fmt.Printf("a->%d,b->%d\n",a,b) } ``` #### 多个变量申明 ```go func main() { var ( a = 1 b = 2.0 ) //输入变量类型 fmt.Printf("a->%T,b->%T\n",a,b) } ``` #### 字符 ```go func main() { var c byte = 'c' fmt.Printf("c->%c,c->%d\n",c,c) //转换大小写 +-32 fmt.Printf("C->%c\n",c-32) } ```