![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
golang
都市无名者
这个作者很懒,什么都没留下…
展开
-
读完整的数据流
var body = make([]byte, 0) var len = 0 for { var buffer = make([]byte, 1024) n, err := c.Request.Body.Read(buffer) if err != nil && err != io.EOF { gLogger.Error("read http body fail...原创 2018-02-08 13:52:13 · 346 阅读 · 0 评论 -
[]int16转[]byte
_Slience = make([]int16, 0) buffer := new(bytes.Buffer) binary.Write(buffer, binary.LittleEndian, _Slience) output := buffer.Bytes()原创 2018-02-06 17:00:29 · 1778 阅读 · 1 评论 -
golang添加json字段
phone_list := "{"phone_list":["a","b","c"]}" var obj map[string]interface{} err := json.Unmarshal([]byte(phone_list), &obj) obj["status"] = 200 output, err := json.Marshal(obj)原创 2018-02-06 17:33:36 · 4602 阅读 · 0 评论 -
golang写文件
f, err := os.OpenFile("./output.pcm", os.O_WRONLY|os.O_TRUNC|os.O_CREATE, os.ModePerm) if err != nil { return } defer f.Close() f.Write(buf)原创 2018-02-06 17:12:10 · 217 阅读 · 0 评论 -
grpc鉴权
服务端 自定义认证 // 注册interceptor var interceptor grpc.StreamServerInterceptor interceptor = func(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {原创 2018-02-06 18:06:12 · 3113 阅读 · 0 评论