v0.0.7版本
方便继承至别的命令里面
type Gen struct {
//curl选项
pcurl.Curl
//自定义选项
Connections string `clop:"-c; --connections" usage:"Connections to keep open"`
Duration time.Duration `clop:"--duration" usage:"Duration of test"`
Thread int `clop:"-t; --threads" usage:"Number of threads to use"`
Latency string `clop:"--latency" usage:"Print latency statistics"`
Timeout time.Duration `clop:"--timeout" usage:"Socket/request timeout"`
}
func main() {
g := &Gen{}
clop.Bind(&g)
// pcurl包里面提供
req, err := g.SetClopAndRequest(clop.CommandLine)
if err != nil {
panic(err.Error())
}
// 已经拿到http.Request对象
// 如果是标准库直接通过Do()方法发送
// 如果是裸socket,可以通过http.DumpRequestOut先转成[]byte再发送到服务端
fmt.Printf("%p\n", req)
}