随笔分类 - go
摘要:make 初始化并指定长度,append函数会把数据添加到长度之后
阅读全文
摘要:package main import ( "flag" "fmt" "net/http" "strings" ) func sendMsg(apiUrl, msg string) { // json contentType := "application/json" // data sendDat
阅读全文
摘要:package main import ( "io" "log" "net/http" ) const form = `<html><body><form action="#" method="post" name="bar"> <input type="text" name="in"/> <inp
阅读全文
摘要:package main import ( "fmt" "net" "net/http" "time" ) var url = []string{ "http://www.baidu.com", "http://google.com", "http://taobao.com", } func mai
阅读全文
摘要:1.读文件 package main import ( "bufio" "fmt" "io" "os" ) //go去读文件内容 func ReadAll(filePth string) string{ file, err := os.Open(filePth) defer file.Close()
阅读全文
摘要:// float 保留2位小数 func Decimal(value float64) float64 { value, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", value), 64) return value } //fload64 --> strin
阅读全文
摘要:1.打印前一天的时间 package main import ( "fmt" "time" ) func main() { timeObj := time.Now() yesTime := timeObj.AddDate(0,0,-1) //时间戳格式化 //var timeFlag1 = time
阅读全文
摘要:package main import "fmt" func main() { n := 2 sInt := fmt.Sprintf("%02d", n) fmt.Println(sInt) }
阅读全文
摘要:1.项目中需要把脚本附件发送给同事邮箱,找了好久 1、安装 gomail 包: go get -v gopkg.in/gomail.v2 2、完整代码: package main import ( "fmt" "gopkg.in/gomail.v2" "mime" ) /* go邮件发送 */ fu
阅读全文
摘要:https://github.com/axgle/mahonia
阅读全文