Skip to content

proposal: time: Duration float scaling method #75265

@croepha

Description

@croepha

Proposal Details

This is kinda annoying:

delay := time.Duration( float64(baseDelay) * backoffFactor )

It would be nicer if you could just do this:

delay := baseDelay.Scale(backoffFactor)

You could paste this in each package you were needing this:

func scaleDuration(d time.Duration, s float64) time.Duration {
	return time.Duration(float64(d) * s)
}

...but probably nicer built into time.Duration?

Have a good day :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    LibraryProposalIssues describing a requested change to the Go standard library or x/ libraries, but not to a toolProposal

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions