-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
232 changed files
with
5,523 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
如果遇到打开是空白,可以在该文件上单击右键,然后选择属性,将”锁定“勾选掉。这样打开就不会空白了。 |
7 changes: 7 additions & 0 deletions
7
传智播客快速入门go语言资料/第01天(基本类型、流程控制)/1-教学资料/go开发实战讲义/Go语言环境搭建/hello.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package main | ||
|
||
import "fmt" // 我们需要fmt包中的Println函数 | ||
|
||
func main() { | ||
fmt.Println("hello world!!!") | ||
} |
Binary file added
BIN
+1020 KB
传智播客快速入门go语言资料/第01天(基本类型、流程控制)/1-教学资料/go开发实战讲义/Go语言环境搭建/ubuntu_liteide.doc
Binary file not shown.
Binary file added
BIN
+1.11 MB
传智播客快速入门go语言资料/第01天(基本类型、流程控制)/1-教学资料/go开发实战讲义/Go语言环境搭建/ubuntu_sublime3.doc
Binary file not shown.
Binary file added
BIN
+466 KB
传智播客快速入门go语言资料/第01天(基本类型、流程控制)/1-教学资料/go开发实战讲义/Go语言环境搭建/windows_liteide.doc
Binary file not shown.
Binary file added
BIN
+1.09 MB
传智播客快速入门go语言资料/第01天(基本类型、流程控制)/1-教学资料/go开发实战讲义/Go语言环境搭建/windows_sublime3.doc
Binary file not shown.
Binary file added
BIN
+4.25 MB
传智播客快速入门go语言资料/第01天(基本类型、流程控制)/1-教学资料/go开发实战讲义/go帮助文档/Golang_Manual_By_AstaXie_20120522.chm
Binary file not shown.
1 change: 1 addition & 0 deletions
1
传智播客快速入门go语言资料/第01天(基本类型、流程控制)/1-教学资料/go开发实战讲义/go帮助文档/readme.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
如果遇到打开是空白,可以在该文件上单击右键,然后选择属性,将”锁定“勾选掉。这样打开就不会空白了。 |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
把程序类比于商场 | ||
|
||
1) 入口, go有且只有一个入口函数, main | ||
liteide, 直接图形界面编译,一个文件夹里的文件只能有一个main函数 | ||
|
||
2) 干活, 调用函数 | ||
|
||
|
||
go build xxx.go | ||
编译go代码,生成一个可执行程序 | ||
然后,运行可执行程序 xxx | ||
|
||
cls: windows清屏命令 | ||
|
||
go run xxx.go //不生成程序,直接运行 | ||
|
||
数据类型 | ||
|
||
计算机用来计算,计算前需要存数,如何存数 | ||
数据类型作用:告诉编译器这个数(变量)应该以多大的内存存储 | ||
|
||
10 | ||
|
||
类型(同一类的数据) | ||
|
||
类型 ===》 成员名字(变量) | ||
命名规范: | ||
1) 字母, 下划线, 数字 | ||
2) 不能以数字开头 | ||
3)名字不能关键字 | ||
4)区分大小写 | ||
|
||
|
||
江氏家族 ===》 江泽民, 江某某 | ||
|
||
|
||
字符类型: | ||
ascii码 | ||
97 ======》 'a' | ||
65 ======> 'A' | ||
|
||
非0就是真,0就是假(但是,go语言的bool类型和int不兼容) | ||
|
||
判断一个数,在0~10的范围 | ||
a := 8 | ||
|
||
0 <= a <= 10 | ||
|
||
|
||
10 - 2 * 8 - 4 ====》 10 - 16 - 4 | ||
|
||
10 - 2 * (8 - 4) ====> 10 - 2 * 4 ====> 10 - 8 = 2 | ||
|
||
|
||
for{ //1 | ||
for{ //2 | ||
break; //跳出的是//2这个循环 | ||
|
||
} | ||
|
||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//1) go语言以包作为管理单位 | ||
//2) 每个文件必须先声明包 | ||
//3) 程序必须有一个main包(重要) | ||
package main | ||
|
||
import "fmt" | ||
|
||
//入口函数 | ||
func main() { //左括号必须和函数名同行 | ||
//打印 | ||
//"hello go"打印到屏幕, Println()会自动换行 | ||
//调用函数,大部分都需要导入包 | ||
/* | ||
这也是注释, 这是块注释 | ||
*/ | ||
fmt.Println("hello go") //go语言语句结尾是没有分号 | ||
|
||
fmt.Println("hello itcast") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package main //必须有一个main包 | ||
|
||
import "fmt" //fmt.Println() | ||
|
||
func main() { | ||
fmt.Println("hello mike") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package main //必须有一个main包 | ||
|
||
import "fmt" //导入包含,必须要使用 | ||
|
||
func main() { | ||
//变量,程序运行期间,可以改变的量 | ||
|
||
//1、声明格式 var 变量名 类型, 变量声明了,必须要使用 | ||
//2、只是声明没有初始化的变量,默认值为0 | ||
//3、同一个{}里,声明的变量名是唯一的 | ||
var a int | ||
fmt.Println("a = ", a) | ||
|
||
//4、可以同时声明多个变量 | ||
//var b, c int | ||
|
||
a = 10 //变量的赋值 | ||
fmt.Println("a = ", a) | ||
|
||
//2、变量的初始化,声明变量时,同时赋值 | ||
var b int = 10 //初始化,声明变量时,同时赋值(一步到位) | ||
b = 20 //赋值, 先声明,后赋值 | ||
fmt.Println("b = ", b) | ||
|
||
//3、自动推导类型,必须初始化,通过初始化的值确定类型(常用) | ||
c := 30 | ||
//%T打印变量所属的类型 | ||
fmt.Printf("c type is %T\n", c) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package main //必须有一个main包 | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
//赋值,赋值前,必须先声明变量 | ||
var a int | ||
a = 10 //赋值,可以使用n次 | ||
a = 20 | ||
a = 30 | ||
fmt.Println("a = ", a) | ||
|
||
//:=, 自动推导类型,先声明变量b,再给b赋值为20 | ||
//自动推导,同一个变量名只能使用一次,用于初始化那次 | ||
b := 20 | ||
fmt.Println("b = ", b) | ||
|
||
//b := 30 //前面已经有变量b,不能再新建一个变量b | ||
|
||
b = 30 //只是赋值,可以的 | ||
fmt.Println("b2 = ", b) | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
传智播客快速入门go语言资料/第01天(基本类型、流程控制)/4-源代码/05_Printf和Println的区别.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package main //必须有一个main包 | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
a := 10 | ||
//一段一段处理,自动加换行 | ||
fmt.Println("a = ", a) | ||
|
||
//格式化输出, 把a的内容放在%d的位置 | ||
// "a = 10\n" 这个字符串输出到屏幕,"\n"代表换行符 | ||
fmt.Printf("a = %d\n", a) | ||
|
||
b := 20 | ||
c := 30 | ||
fmt.Println("a = ", a, ", b = ", b, ", c = ", c) | ||
fmt.Printf("a = %d, b = %d, c = %d\n", a, b, c) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package main //必须有一个main包 | ||
|
||
import "fmt" | ||
|
||
//go函数可以返回多个值 | ||
func test() (a, b, c int) { | ||
return 1, 2, 3 | ||
} | ||
|
||
func main() { | ||
// a := 10 | ||
// b := 20 | ||
// c := 30 | ||
|
||
a, b := 10, 20 | ||
|
||
//交换2个变量的值 | ||
var tmp int | ||
tmp = a | ||
a = b | ||
b = tmp | ||
fmt.Printf("a = %d, b = %d\n", a, b) | ||
|
||
// i := 10 | ||
// j := 20 | ||
i, j := 10, 20 | ||
i, j = j, i | ||
fmt.Printf("i = %d, j = %d\n", i, j) | ||
|
||
i = 10 | ||
j = 20 | ||
|
||
//_匿名变量,丢弃数据不处理, _匿名变量配合函数返回值使用,才有优势 | ||
tmp, _ = i, j | ||
fmt.Println("tmp = ", tmp) | ||
|
||
var c, d, e int | ||
c, d, e = test() //return 1, 2, 3 | ||
fmt.Printf("c = %d, d = %d, e = %d\n", c, d, e) | ||
|
||
_, d, e = test() //return 1, 2, 3 | ||
fmt.Printf("d = %d, e = %d\n", d, e) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package main //必须有一个main包 | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
//变量:程序运行期间,可以改变的量, 变量声明需要var | ||
//常量:程序运行期间,不可以改变的量,常量声明需要const | ||
|
||
const a int = 10 | ||
//a = 20 //err, 常量不允许修改 | ||
fmt.Println("a = ", a) | ||
|
||
const b = 11.2 //没有使用:= | ||
fmt.Printf("b type is %T\n", b) | ||
fmt.Println("b = ", b) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package main //必须有一个main包 | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
//不同类型变量的声明(定义) | ||
// var a int = 1 | ||
// var b float64 = 2.0 | ||
// var ( | ||
// a int = 1 | ||
// b float64 = 2.0 | ||
// ) | ||
|
||
//可以自动推导类型 | ||
var ( | ||
a = 1 | ||
b = 2.0 | ||
) | ||
|
||
a, b = 10, 3.14 | ||
fmt.Println("a = ", a) | ||
fmt.Println("b = ", b) | ||
//选中代码,按ctrl+\, 注释和取消注释代码的快捷键 | ||
// const i int = 10 | ||
// const j float64 = 3.14 | ||
|
||
// const ( | ||
// i int = 10 | ||
// j float64 = 3.14 | ||
// ) | ||
|
||
//可以自动推导类型 | ||
const ( | ||
i = 10 | ||
j = 3.14 | ||
) | ||
|
||
fmt.Println("i = ", i) | ||
fmt.Println("j = ", j) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package main //必须有一个main包 | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
//1、iota常量自动生成器,每个一行,自动累加1 | ||
//2、iota给常量赋值使用 | ||
const ( | ||
a = iota //0 | ||
b = iota //1 | ||
c = iota //2 | ||
) | ||
fmt.Printf("a = %d, b = %d, c = %d\n", a, b, c) | ||
|
||
//3、iota遇到const,重置为0 | ||
const d = iota | ||
fmt.Printf("d = %d\n", d) | ||
|
||
//4、可以只写一个iota | ||
const ( | ||
a1 = iota //0 | ||
b1 | ||
c1 | ||
) | ||
fmt.Printf("a1 = %d, b1 = %d, c1 = %d\n", a1, b1, c1) | ||
|
||
//5、如果是同一行,值都一样 | ||
const ( | ||
i = iota | ||
j1, j2, j3 = iota, iota, iota | ||
k = iota | ||
) | ||
fmt.Printf("i = %d, j1 = %d, j2 = %d, j3 = %d, k = %d\n", i, j1, j2, j3, k) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package main //必须有一个main包 | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
//1、声明变量, 没有初始化,零值(初始值)为false | ||
var a bool | ||
fmt.Println("a0 = ", a) | ||
|
||
a = true | ||
fmt.Println("a = ", a) | ||
|
||
//2、自动推导类型 | ||
var b = false | ||
fmt.Println("b = ", b) | ||
|
||
c := false | ||
fmt.Println("c = ", c) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package main //必须有一个main包 | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
//声明变量 | ||
var f1 float32 | ||
f1 = 3.14 | ||
fmt.Println("f1 = ", f1) | ||
|
||
//自动推导类型 | ||
f2 := 3.14 | ||
fmt.Printf("f2 type is %T\n", f2) //f2 type is float64 | ||
|
||
//float64存储小数比float32更准确 | ||
|
||
} |
Oops, something went wrong.