aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/charithe/durationcheck/README.md
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2021-02-22 20:37:25 +0100
committerDmitry Vyukov <dvyukov@google.com>2021-02-22 21:02:12 +0100
commitfcc6d71be2c3ce7d9305c04fc2e87af554571bac (patch)
treeb01dbb3d1e2988e28ea158d2d543d603ec0b9569 /vendor/github.com/charithe/durationcheck/README.md
parent8f23c528ad5a943b9ffec5dcaf332fd0f614006e (diff)
go.mod: update golangci-lint to v1.37
Diffstat (limited to 'vendor/github.com/charithe/durationcheck/README.md')
-rw-r--r--vendor/github.com/charithe/durationcheck/README.md48
1 files changed, 48 insertions, 0 deletions
diff --git a/vendor/github.com/charithe/durationcheck/README.md b/vendor/github.com/charithe/durationcheck/README.md
new file mode 100644
index 000000000..122edb745
--- /dev/null
+++ b/vendor/github.com/charithe/durationcheck/README.md
@@ -0,0 +1,48 @@
+[![CircleCI](https://circleci.com/gh/charithe/durationcheck.svg?style=svg)](https://circleci.com/gh/charithe/durationcheck)
+
+
+
+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:
+
+```go
+func waitFor(someDuration time.Duration) {
+ timeToWait := someDuration * time.Second
+ time.Sleep(timeToWait)
+}
+```
+
+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.
+
+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.
+
+
+Installation
+-------------
+
+Requires Go 1.11 or above.
+
+```
+go get -u github.com/charithe/durationcheck/cmd/durationcheck
+```
+
+Usage
+-----
+
+Invoke `durationcheck` with your package name
+
+```
+durationcheck ./...
+# or
+durationcheck github.com/you/yourproject/...
+```