跳至主要內容
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?

4563博客

全新的繁體中文 WordPress 網站
  • 首頁
  • golang 实现的 http client 库,新版本带来新功能(gout-v0.0.12)
未分類
26 5 月 2020

golang 实现的 http client 库,新版本带来新功能(gout-v0.0.12)

golang 实现的 http client 库,新版本带来新功能(gout-v0.0.12)

資深大佬 : guonaihong 2

gout

golang 实现的 http 请求库。本次版本带来一些细节上的优化。http 请求库作用是让你发送 json/formdata 之类数据更 easy,bind 数据更爽。gout 除了是 restful api 库还是压测 lib,可以完成 ab, wrk 完成的工作。

版本及地址

本次版本是 v0.0.12
https://github.com/guonaihong/gout

下个版本计划

提升压测子模块的吞吐效率。

压测功能回顾

自定义压测函数,构造每次不一样的 http request 数据。 相比 wrk 需要写 lua,在 go lib 里面解决自定义压测会更 easy

package main  import (     "fmt"     "github.com/google/uuid"     "github.com/guonaihong/gout"     "github.com/guonaihong/gout/filter"     "sync/atomic" )  func main() {     i := int32(0)      err := filter.NewBench().         Concurrent(30). //开 30 个 go 程         Number(30000).  //压测 30000 次         Loop(func(c *gout.Context) error {     // 下面的代码,每次生成不一样的 http body 用于压测             uid := uuid.New()  //生成 uuid             id := atomic.AddInt32(&i, 1) //生成 id, 可以理解为++i,线程安全版本              c.POST(":1234").SetJSON(gout.H{"sid": uid.String(),                 "appkey": fmt.Sprintf("ak:%d", id),                 "text":   fmt.Sprintf("test text :%d", id)}) //这里不要运行 Do()函数             return nil          }).Do()      if err != nil {         fmt.Printf("err = %vn", err)     } } 

大佬有話說 (5)

  • 資深大佬 : wysnylc

    python 党出来,就照这样写个轮子

  • 資深大佬 : lasuar

    也用 go,给个 star !

  • 主 資深大佬 : guonaihong

    @lasuar 感谢支持。。。

  • 主 資深大佬 : guonaihong

    @wysnylc 看过你的留言,哈哈,你不是用 java 的吗。。。

  • 資深大佬 : wysnylc

    @guonaihong #4 Java 只是副业,主业是键盘侠

文章導覽

上一篇文章
下一篇文章

AD

其他操作

  • 登入
  • 訂閱網站內容的資訊提供
  • 訂閱留言的資訊提供
  • WordPress.org 台灣繁體中文

51la

4563博客

全新的繁體中文 WordPress 網站
返回頂端
本站採用 WordPress 建置 | 佈景主題採用 GretaThemes 所設計的 Memory
4563博客
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?
在這裡新增小工具