Comments (5)
An underlying type of time.Duration is int64.
Therefore, you need to specify integer values (in nanoseconds) such that:
type MyStruct struct {
BackoffPolicy []time.Duration `default:"[10000000000,60000000000]"` // 10s, 1m
}
#32 might be what you're looking for — pull requests are welcome.
from defaults.
Here - https://github.com/creasty/defaults/blob/master/defaults.go#L86 code is trying to parse string and in test file i can find
Duration time.Duration `default:"10s"`
https://github.com/creasty/defaults/blob/master/defaults_test.go#L48
What made me confused that in slice i need to change behavior)))
from defaults.
Here - https://github.com/creasty/defaults/blob/master/defaults.go#L86 code is trying to parse string and in test file i can find
Ahhh...
Thanks, I'll fix that test code later!
from defaults.
@creasty using int64
to specify Duration
is very ugly. string representation of duration
is very useful in config file.
from defaults.
Sorry for the oversight!
Reading over the discussion again, I recognize that I missed the point.
I had a lapse in memory regarding supporting the string representation of Duration, leading to my assumption that it never worked.
from defaults.
Related Issues (20)
- Wrong example in Readme? HOT 1
- Default value for slice of struct doesn't work for golang v 1.12 HOT 2
- Default true on bool does not allow to set false HOT 1
- The Setter interface only works on struct pointer fields, not the struct itself
- bug: not set default for fields of a pointer struct field in an object.
- Add MustSet() function HOT 1
- Default values map[string][]string for struct HOT 2
- Default value to the entry that key already exists in a map HOT 5
- Booleans and defaults seems not to be working HOT 2
- Unable to keep zero value in case of setting the zero value on purpose HOT 2
- Customizable value filler
- Add require field tag
- bool is false default is true, handler is true HOT 1
- Support unmarshalling custom types.
- Unset() HOT 1
- Panic when attempting to initialize a field which references an interface HOT 1
- Struct tag boolean values are not parsed properly when specified with double quotes HOT 4
- no errors if default value doesn't parse HOT 1
- How to support slice of struct? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from defaults.