v0.2.7版本
支持设置回调函数, 让clop支持任意类型的数据绑定。
type TestCallback struct {
Size int `clop:"short;long;callback=ParseSize" usage:"parse size"`
Max int `clop:"short;long"`
}
func (t *TestCallback) ParseSize(val string) {
// 做些解析工作
// t.Size = 解析之后的值
}
func main() {
t := TestCallback{}
err := clop.Bind(&t)
fmt.Printf("%#v, %s\n", t, err)
}