mirror of
https://github.com/Crocmagnon/fatcontext.git
synced 2024-11-21 15:38:08 +01:00
Compare commits
9 commits
548d1beeac
...
fbf73fbd4d
Author | SHA1 | Date | |
---|---|---|---|
|
fbf73fbd4d | ||
|
ed98e56f00 | ||
|
7f2b12beab | ||
|
9b1b0c8986 | ||
|
1c05d23bb3 | ||
|
e1e94fa7d4 | ||
|
db40be2dee | ||
|
0c76b071d6 | ||
|
cddb074802 |
3 changed files with 22 additions and 21 deletions
18
.github/workflows/go.yml
vendored
18
.github/workflows/go.yml
vendored
|
@ -29,3 +29,21 @@ jobs:
|
||||||
run: go build -v ./...
|
run: go build -v ./...
|
||||||
- name: Test
|
- name: Test
|
||||||
run: make test
|
run: make test
|
||||||
|
coverage:
|
||||||
|
name: coverage
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
concurrency:
|
||||||
|
group: coverage
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [build]
|
||||||
|
steps:
|
||||||
|
- name: Update coverage report
|
||||||
|
uses: ncruces/go-coverage-report@v0
|
||||||
|
with:
|
||||||
|
report: true
|
||||||
|
chart: true
|
||||||
|
amend: true
|
||||||
|
if: |
|
||||||
|
github.event_name == 'push'
|
||||||
|
continue-on-error: true
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
# fatcontext
|
# fatcontext
|
||||||
|
|
||||||
|
[![Go Reference](https://pkg.go.dev/badge/github.com/Crocmagnon/fatcontext.svg)](https://pkg.go.dev/github.com/Crocmagnon/fatcontext)
|
||||||
|
[![Go Report Card](https://goreportcard.com/badge/github.com/Crocmagnon/fatcontext)](https://goreportcard.com/report/github.com/Crocmagnon/fatcontext)
|
||||||
|
[![Go Coverage](https://github.com/Crocmagnon/fatcontext/wiki/coverage.svg)](https://github.com/Crocmagnon/fatcontext/wiki/Coverage)
|
||||||
|
|
||||||
`fatcontext` is a Go linter which detects potential fat contexts in loops or function literals.
|
`fatcontext` is a Go linter which detects potential fat contexts in loops or function literals.
|
||||||
They can lead to performance issues, as documented here: https://gabnotes.org/fat-contexts/
|
They can lead to performance issues, as documented here: https://gabnotes.org/fat-contexts/
|
||||||
|
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
package contrib
|
|
||||||
|
|
||||||
import "context"
|
|
||||||
|
|
||||||
func ok() {
|
|
||||||
ctx := context.Background()
|
|
||||||
|
|
||||||
for i := 0; i < 10; i++ {
|
|
||||||
ctx := context.WithValue(ctx, "key", i)
|
|
||||||
_ = ctx
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func notOk() {
|
|
||||||
ctx := context.Background()
|
|
||||||
|
|
||||||
for i := 0; i < 10; i++ {
|
|
||||||
ctx = context.WithValue(ctx, "key", i) // "nested context in loop"
|
|
||||||
_ = ctx
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue