2022-4-12 实习Day12

1、tf-exi开发包结构注释规范标记检验,格式优化–3小时 100%
2、数据库全量升级 –1小时 100%
3、客户管理模块测试,发现表格导出错误。–2小时 100%
4、机构、客户测试数据配置 –2小时 50%

Golang编程学习(part 7)

1、程序流程控制

① 顺序控制:程序从上到下逐行执行,中间没有任何判断和跳转。
② 分支控制:单分支、双分支、多分支
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//【1】. 当条件表达式为true时,就会执行{}中代码
if `条件` {
//代码块
}

//【2】. 当条件表达式成立,即执行代码块1,否则执行代码块2
if `条件` {
//代码块1
} else {
//代码块2
}

//【3】. 先判断条件表达式1是否成立,如果为真,就执行代码块1。
// 如何条件表达式1为假的,就去判断条件表达式2是否成立,如果条件表达式2为真,就执行代码块2。
// 以此类推,如果所有的条件表达式不成立,则执行else的语句块。else也不是必须的
if `条件1` {
//执行代码块1
} else if `条件2` {
//执行代码块2
}……
else {
//执行代码块n
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// switch分支控制
// 【1】.switch语句用于基于不同条件执行不同动作,每一个case分支都是唯一的,从上到下试,直到匹配为止。
// 【2】.匹配项后面也不需要再加break
switch `表达式` {
case `表达式1`,`表达式2`,...:
语句块1
case `表达式3`,`表达式4`,...:
语句块2
//这里可以有多个case语句
default:
语句块3
}

// switch使用的注意事项
//【1】. case/switch后是一个表达式(常量值、变量、一个有返回值的函数等都可以)
//【2】. case后的各个表达式的值的数据类型,必须和switch的表达式数据类型一致
//【3】. case后面可以带多个表达式,使用逗号间隔。比如case 表达式1,表达式2...
//【4】. case后面的表达式如果是常量值(字面量),则要求不能重复(用变量代表某个数会骗过编译器)
//【5】. case后面不需要带break,程序匹配到一个case后就会执行对应的代码块,然后退出switch,如果一个都匹配不到,则执行default
//【6】. default语句不是必须的
//【7】. switch后也可以不带表达式,类似if-else分支来使用。
var age int = 10
switch{
case age==10:
fmt.Println("age==10")
case age==20:
fmt.Println("age==10")
default:
fmt.Println("没有匹配到")

}

1
2
3
4
5
6
7
8
9
10
11
12
13

// case中也可以对范围进行判断
var score int = 90
switch{
case score > 90:
fmt.Println("成绩优秀..")
case score >= 70 && score <= 90:
fmt.Println("成绩优良..")
case score >= 60 && score < 70:
fmt.Println("成绩及格..")
default:
fmt.Println("不及格")
}
1
2
3
4
5
6
7
8
9
10
11
// switch 后也可以直接声明/定义一个变量,分号结束,不推荐
switch grade:=90; {
case grade > 90:
fmt.Println("成绩优秀~..")
case grade >= 70 && grade <= 90:
fmt.Println("成绩优良~..")
case grade >= 60 && grade < 70:
fmt.Println("成绩及格~..")
default:
fmt.Println("不及格~")
}
1
2
3
4
5
6
7
8
9
10
11
12
13
// switch 穿透-fallthrough ,如果在 case 语句块后增加 fallthrough ,则会继续执行下一个 case,也叫 switch 穿透
var num int = 10
switch num {
case 10:
fmt.Println("成绩优秀~..")
fallthrough //默认只能穿透一层
case 20:
fmt.Println("成绩优良~..")
case 30:
fmt.Println("成绩及格~..")
default:
fmt.Println("不及格~")
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Type Switch:switch 语句还可以被用于 type-switch 来判断某个 interface 变量中实际指向的变量类型 【还没有学 interface,  先体验一把】
var x interface{}
var y = 10.0
x=y
switch i:=x.(type) {
case nil:
fmt.Printf("x的类型~ %T",i)
case int:
fmt.Printf("x是int型")
case float64:
fmt.Printf("x是float64型")
case func(int) float64:
fmt.Printf("x是func(int)型")
case bool, string:
fmt.Printf("x是bool 或 string型")
default:
fmt.Println("未知")
}