Git Product home page Git Product logo

Comments (5)

creasty avatar creasty commented on June 28, 2024

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.

ergoz avatar ergoz commented on June 28, 2024

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.

creasty avatar creasty commented on June 28, 2024

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.

yuyang0 avatar yuyang0 commented on June 28, 2024

@creasty using int64 to specify Duration is very ugly. string representation of duration is very useful in config file.

from defaults.

creasty avatar creasty commented on June 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.