摘要: 1. 数组 go中的数组需要提前定义好长度 初始化 1 var course [3]string course[0] = "go" course[1] = "grpc" course[2] = "gin" 初始化 2 course := [3]string{"go", "grpc", "gin"} 阅读全文
posted @ 2023-03-09 22:22 ForLivetoLearn 阅读(18) 评论(0) 推荐(0) 编辑
摘要: if条件判断 if age > 18 { } else if age == 18 { } else { } switch语句 score := 80 switch score { case 60, 70, 80: fmt.Println("一般") case 90, 100: fmt.Println 阅读全文
posted @ 2023-03-09 16:40 ForLivetoLearn 阅读(25) 评论(0) 推荐(0) 编辑
摘要: 字符串常用方法都在strings包中 高性能字符串拼接 var builder strings.Builder builder.WriteString("用户名") builder.WriteByte(97) str := builder.String() fmt.Println(str) 包含字符 阅读全文
posted @ 2023-03-09 15:40 ForLivetoLearn 阅读(22) 评论(0) 推荐(0) 编辑
摘要: 通常使用 str := fmt.Sprintf("%d", a) fmt.Printf("%s", str) 缺省格式和类型 | 格式化后效果 | 格式 | 描述 | | | | | | [0 1] | %v | 缺省格式 | | []int64{0, 1} | %#v | go语言打印 | | [ 阅读全文
posted @ 2023-03-09 14:13 ForLivetoLearn 阅读(59) 评论(0) 推荐(0) 编辑
摘要: 1. 算数运算符 如: + - * / ... 2. 关系运算符 == != > < >= <= 3. 逻辑运算符 | 运算符 | 含义 | | | | | && | 与运算。如果两个操作数都⾮零,则条件变为真 | | || | 或运算。如果任何两个操作数是⾮零,则条件变为真 | | ! | ⾮运算 阅读全文
posted @ 2023-03-09 13:08 ForLivetoLearn 阅读(9) 评论(0) 推荐(0) 编辑