摘要: 时间类型 // timeDemo 时间对象的年月日时分秒 func timeDemo() { now := time.Now() // 获取当前时间 fmt.Printf("current time:%v\n", now) year := now.Year() // 年 day := now.Day 阅读全文
posted @ 2022-12-17 23:08 topass123 阅读(226) 评论(0) 推荐(0) 编辑
摘要: strconv与之前的strings有本质的区别。他不仅仅局限于字符本身的功能与字节的转化,还提供可int,bool的多种数据类型的解析 string 与 int 类型之间的转换 Atoi():字符串转整型 Itoa():整型转字符串 Parse 系列函数 Parse 系列函数用于将字符串转换为指定 阅读全文
posted @ 2022-12-17 22:56 topass123 阅读(22) 评论(0) 推荐(0) 编辑
摘要: os package main import ( "log" "os" ) func main() { // 1.文件的基础操作,create/open/close/chmod -> go/io库 f, err := os.Create("create.txt") if err != nil { l 阅读全文
posted @ 2022-12-17 22:28 topass123 阅读(21) 评论(0) 推荐(0) 编辑
摘要: json的序列化【本质是转化为可传输的二进制】 type Monster struct { Name string //如果改成小写,序列化时跨包会丢掉此字段 Age int `json:"age"` //代表json过后的重命名 Score float64 } func testStruct() 阅读全文
posted @ 2022-12-17 21:57 topass123 阅读(7) 评论(0) 推荐(0) 编辑
摘要: 字符串涉及的用法strings 1)统计 strings.Count 2)替换 strings.Replace() 3)组合 strings.Join() 4)清洗 strings.Trim() 5)查找子串 strings.Index();strings.Contains() 6)分割 strin 阅读全文
posted @ 2022-12-17 21:46 topass123 阅读(57) 评论(0) 推荐(0) 编辑