clop v0.0.8 版本更新,Golang 实现的命令行选项解析库

栏目: 软件资讯 · 发布时间: 5年前

内容简介:changelog see #48 数据格式为slice时,清空default的数据 package main import ( "log" "github.com/guonaihong/clop" ) type A struct { Name []int `clop:"-e" usage:"数组测试" valid:"requ...

changelog

see #48 数据格式为slice时,清空default的数据

package main

import (
	"log"

	"github.com/guonaihong/clop"
)

type A struct {
	Name []int `clop:"-e" usage:"数组测试" valid:"required" default:"[1,2]"`
}

func main() {
	a := A{}
	err := clop.Bind(&a)
	if err != nil {
		log.Fatal(err)
	}
	log.Printf("%+v\n", a)
}
// v0.0.8版本之前,此代码执行时,命令行输入 ./test.exe -e 3 -e 4,输出的结果是[1 2 3 4]
// v0.0.8版本 结果为[3, 4]

项目地址

https://gitee.com/guonaihong/clop

https://github.com/guonaihong/clop

 


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

The Practice of Programming

The Practice of Programming

Brian W. Kernighan、Rob Pike / Addison-Wesley / 1999-2-14 / USD 49.99

With the same insight and authority that made their book The Unix Programming Environment a classic, Brian Kernighan and Rob Pike have written The Practice of Programming to help make individual progr......一起来看看 《The Practice of Programming》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

MD5 加密
MD5 加密

MD5 加密工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具