go
hhg08
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
go 安装package 命令
go get 无法使用或者使用起来特别慢,使用gopm(1)go get -u github.com/gpmgo/gopm(2)gopm get -g package_name-g 是直接放到你的全局GOPATH里得go build原创 2016-04-27 11:49:22 · 510 阅读 · 0 评论 -
go两种方式读取http.Request数据
buf := new(bytes.Buffer) buf.ReadFrom(r.Body) fmt.Println(buf.String()) //第二种方式 res,_:=ioutil.ReadAll(r.Body) fmt.Println(string(res))原创 2016-06-14 12:24:31 · 6009 阅读 · 0 评论 -
go method的receiver是一个指针与结构的一点区别
type Box struct { color Color}func (b *Box) SetColor(c Color) { b.color = c}func (b Box) SetColor(c Color){ b.color = c}现在让我们回过头来看看SetColor这个method,它的receiver是一个指向Box的指针,是...原创 2016-03-11 14:27:34 · 319 阅读 · 0 评论 -
go动态调用方法
func CallMethod(i interface{}, methodName string) interface{} { var ptr reflect.Value var value reflect.Value var finalMethod reflect.Value value = reflect.ValueOf(i) // i...原创 2016-03-16 15:11:49 · 524 阅读 · 0 评论 -
go语言测试代码
使用两个包 . "github.com/onsi/ginkgo" . "github.com/onsi/gomega"github:https://github.com/onsi/ginkgo文章:http://onsi.github.io/ginkgo/#measuring-time使用duck typing方式多创建接口,放入不同的构造中,然后另建结构实现,...原创 2016-03-17 18:25:47 · 147 阅读 · 0 评论 -
go处理protobuf文件
protobuf提供两个包(1)proto(2)protoc-gen-go前者负责处理处理protobuf的goprotocbuf编码、解码,后者作为编译器插件使用。(1)使用方式 error:= proto.Unmarshal([]byte(media_request_str), &bidreq)负责把字符串流解析解码到一个结构体bidreq。如果有错,err不...原创 2016-03-28 11:06:40 · 548 阅读 · 0 评论 -
go 如何把结构体变成一个map
https://github.com/fatih/structs使用方式:m:= structs.Map(server) .Values()获取值..原创 2016-03-28 11:13:33 · 1547 阅读 · 0 评论
分享