From b2f2446b46bf02821d90ebedadae2bf7ae0e880e Mon Sep 17 00:00:00 2001 From: Taras Madan Date: Mon, 5 Sep 2022 14:27:54 +0200 Subject: go.mod, vendor: update (#3358) * go.mod, vendor: remove unnecessary dependencies Commands: 1. go mod tidy 2. go mod vendor * go.mod, vendor: update cloud.google.com/go Commands: 1. go get -u cloud.google.com/go 2. go mod tidy 3. go mod vendor * go.mod, vendor: update cloud.google.com/* Commands: 1. go get -u cloud.google.com/storage cloud.google.com/logging 2. go mod tidy 3. go mod vendor * go.mod, .golangci.yml, vendor: update *lint* Commands: 1. go get -u golang.org/x/tools github.com/golangci/golangci-lint@v1.47.0 2. go mod tidy 3. go mod vendor 4. edit .golangci.yml to suppress new errors (resolved in the same PR later) * all: fix lint errors hash.go: copy() recommended by gosimple parse.go: ent is never nil verifier.go: signal.Notify() with unbuffered channel is bad. Have no idea why. * .golangci.yml: adjust godot rules check-all is deprecated, but still work if you're hesitating too - I'll remove this commit --- vendor/github.com/charithe/durationcheck/README.md | 23 ++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'vendor/github.com/charithe/durationcheck/README.md') diff --git a/vendor/github.com/charithe/durationcheck/README.md b/vendor/github.com/charithe/durationcheck/README.md index 122edb745..6f4279bd3 100644 --- a/vendor/github.com/charithe/durationcheck/README.md +++ b/vendor/github.com/charithe/durationcheck/README.md @@ -7,22 +7,25 @@ Duration Check A Go linter to detect cases where two `time.Duration` values are being multiplied in possibly erroneous ways. -For example, consider the following (highly contrived) function: +Consider the following (highly contrived) code: ```go -func waitFor(someDuration time.Duration) { - timeToWait := someDuration * time.Second - time.Sleep(timeToWait) +func waitForSeconds(someDuration time.Duration) { + timeToWait := someDuration * time.Second + fmt.Printf("Waiting for %s\n", timeToWait) +} + +func main() { + waitForSeconds(5) // waits for 5 seconds + waitForSeconds(5 * time.Second) // waits for 1388888h 53m 20s } ``` -Although the above code would compile without any errors, its runtime behaviour would almost certainly be incorrect. -A caller would reasonably expect `waitFor(5 * time.Seconds)` to wait for ~5 seconds but they would actually end up -waiting for ~1,388,889 hours. +Both invocations of the function are syntactically correct but the second one is probably not what most people want. +In this contrived example it is quite easy to spot the mistake. However, if the incorrect `waitForSeconds` invocation is +nested deep within a complex piece of code that runs in the background, the mistake could go unnoticed for months (which +is exactly what happened in a production backend system of fairly well-known software service). -The above example is just for illustration purposes only. The problem is glaringly obvious in such a simple function -and even the greenest Gopher would discover the issue immediately. However, imagine a much more complicated function -with many more lines and it is not inconceivable that such logic errors could go unnoticed. See the [test cases](testdata/src/a/a.go) for more examples of the types of errors detected by the linter. -- cgit mrf-deployment