package main import ( "fmt" "io/ioutil" "net/http" "time" ) func main() { client := &http.Client{ Timeout: 2 * time.Second, } req, _ := http.NewRequest("GET", "http://www.xxxx.vip", nil) req...
package main import ( "fmt" "syscall" "unicode/utf16" "unsafe" ) var( kernel=syscall.MustLoadDLL("kernel32.dll") getModuleFileNameProc = kernel.MustFindProc("GetModuleFileNameW") ) func getExePath() (exePath s...
package main import ( "net/http" "net/url" "fmt" "io/ioutil" ) func main() { //?mod=forumdisplay&fid=42 params:=url.Values{ "action":{"add"}, "name":{"42"}, "tel":{"13...
package main import ( "fmt" ) func main() { str := "Hello,世界" //方法一:格式化打印 for _, ch1 := range str { fmt.Printf("%q",ch1) //单引号围绕的字符字面值,由go语法安全的转义 } fmt.Println("==========>方法二") //方法二:转化输出格式 for _, ch2 := range s...
package main import ( "fmt" "regexp" ) func main(){ r,_:=regexp.Compile("aaa(.*?)bbb") matches:=r.FindAllString("42342342aaa111111111111bbbasdfafasdfas",-1) // %q quote element to see... instead of %s fmt.Printf("%q \n"...
examplepackage main import "fmt" import "github.com/axgle/mahonia" func main(){ enc:=mahonia.NewEncoder("gbk") //converts a string from UTF-8 to gbk encoding. fmt.Println(enc.ConvertString("hello,世界")) }
golang处理中文时默认是utf8,当遇到其他如GBK字符是就会出现乱码,此处介绍golang 官方golang.org/x/text/encoding/simplifiedchinese包下的编码转换package main import "golang.org/x/text/encoding/simplifiedchinese" type Charset string const ( UTF8 = Charset("UTF-8") GB18030 = Charset("GB18030") ) fu...
go 语言模拟百度登录1.参考网上Python的例子自己写了一个go语言的。这个仅供学习技术参考,为了方便有部分参数直接phantomjs执行js获取,代码基本都有注释,测试打印没有删除,还请见谅!2.本文参考http://blog.csdn.net/qiye_/article/details/52884491话不多说,直接上码package main import ( "errors" "fmt" "math/big" "crypto/rsa" "byt...
//获取unix时间 func getMillisecond() int64{ MS := time.Now().Unix() return MS }
mysql 按日期统计按年汇总,统计:select sum(mymoney) as totalmoney, count(*) as sheets from mytable group by date_format(col, '%Y');按月汇总,统计: select sum(mymoney) as totalmoney, count(*) as sheets from mytable group by date_format(col, '%Y-%m');按季度汇总,统计: select sum(mymoney) as totalmoney,count(*) as sheets from ...