
go
初级使用者
这个作者很懒,什么都没留下…
展开
-
json与byte[]转换
type data struct { ExpireTime string `json:"expire_time"` Token string `json:"token"`}type Authorization struct { Code int `json:"code"` Msg string `json:"msg"` Data data `json:"data"`}var authorization Authorizationjson.Unmarshal(b原创 2021-03-01 21:44:23 · 3681 阅读 · 0 评论 -
go http 请求
/*http请求*/func HttpPostRequest(urls string, datas map[string]string) string { data := url.Values{} for index := range datas { data.Add(index, datas[index]) } res, _ := http.PostForm(urls, data) if res.StatusCode != 200 { } body, _ := ioutil.Re原创 2021-03-01 21:41:14 · 318 阅读 · 0 评论 -
go sql报错: converting argument $1 type: unsupported type []interface {}, a slice of interface
sql 执行 exec源码,如下:// Exec executes a prepared statement with the given arguments and// returns a Result summarizing the effect of the statement.func (s *Stmt) Exec(args ...interface{}) (Result, error) { return s.ExecContext(context.Background(), args...原创 2021-03-01 19:44:04 · 13066 阅读 · 0 评论 -
布隆过滤器
目的:当在一个大的数据空间中查询某一个数据时,如果要查询的数据特别多,那么每次都遍历查询该空间,会导致出现慢查及占用大量本地内存,为了解决该现象,使用布隆过滤器。原理:bloom算法类似一个hash set,用来判断某个元素(key)是否在某个集合中。算法实现:首先需要k个hash函数,每个函数可以把key散列成为1个整数初始化时,需要一个长度为n比特的数组,每个比特位初始化为0某个key加入集合时,用k个hash函数计算出k个散列值,并把数组中对应的比特位置为1判断某个key是否在集合时,用原创 2020-12-15 16:18:24 · 103 阅读 · 0 评论 -
类型转换
string转成int:int, err := strconv.Atoi(string)string转成int64:int64, err := strconv.ParseInt(string, 10, 64)int转成string:string := strconv.Itoa(int)int64转成string:string := strconv.FormatInt(int64,10)原创 2020-12-10 22:03:52 · 132 阅读 · 0 评论 -
go-写文件追加
func Writefile(filename string, str string) { if checkFileExist(filename) { f, err1 = os.OpenFile(filename, os.O_WRONLY|os.O_APPEND, 0666) fmt.Println("文件存在") } else { f, err1 = os.Create(filename) fmt.Println("文件不存在") } defer f.Close() //写入文件原创 2020-12-10 22:00:22 · 565 阅读 · 0 评论 -
go 基础知识
import _“github.com/pkg/errors”讲解:使用【import _ 包路径】只是引用该包,仅仅是为了调用init()函数,无法通过包名来调用包中的其他函数原创 2020-10-12 10:37:00 · 100 阅读 · 0 评论