38f8eb7c6b
The patch makes sure that both values and pointer to values are checked for custom TextUnmarshal implementation. This will allow to use go-arg custom parsing as follows: var args struct { Arg CustomType } instead of var args struct { Arg *CustomType } Signed-off-by: Pavel Borzenkov <pavel.borzenkov@gmail.com> |
||
---|---|---|
.gitignore | ||
.travis.yml | ||
LICENSE | ||
README.md | ||
scalar.go | ||
scalar_test.go |
README.md
Scalar parsing library
Scalar is a library for parsing strings into arbitrary scalars (integers, floats, strings, booleans, etc). It is helpful for tasks such as parsing strings passed as environment variables or command line arguments.
go get github.com/alexflint/go-scalar
The main API works as follows:
var value int
err := scalar.Parse(&value, "123")
There is also a variant that takes a reflect.Value
:
var value int
err := scalar.ParseValue(reflect.ValueOf(&value), "123")