摘要: 1.读文件 package main import ( "bufio" "fmt" "io" "os" ) //go去读文件内容 func ReadAll(filePth string) string{ file, err := os.Open(filePth) defer file.Close() 阅读全文
posted @ 2021-12-07 16:40 随心朝阳 阅读(69) 评论(0) 推荐(0) 编辑
摘要: // float 保留2位小数 func Decimal(value float64) float64 { value, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", value), 64) return value } //fload64 --> strin 阅读全文
posted @ 2021-12-07 16:30 随心朝阳 阅读(1214) 评论(0) 推荐(0) 编辑
摘要: 1.打印前一天的时间 package main import ( "fmt" "time" ) func main() { timeObj := time.Now() yesTime := timeObj.AddDate(0,0,-1) //时间戳格式化 //var timeFlag1 = time 阅读全文
posted @ 2021-12-07 16:25 随心朝阳 阅读(391) 评论(0) 推荐(0) 编辑
摘要: package main import "fmt" func main() { n := 2 sInt := fmt.Sprintf("%02d", n) fmt.Println(sInt) } 阅读全文
posted @ 2021-12-07 16:17 随心朝阳 阅读(740) 评论(0) 推荐(0) 编辑