mirror of
https://github.com/Crocmagnon/fatcontext.git
synced 2024-11-22 07:58:05 +01:00
Compare commits
No commits in common. "fbf73fbd4dad493c4b8313cfa777b7515a561431" and "548d1beeacf1b232125932b4249ed25be5f892d1" have entirely different histories.
fbf73fbd4d
...
548d1beeac
3 changed files with 21 additions and 22 deletions
18
.github/workflows/go.yml
vendored
18
.github/workflows/go.yml
vendored
|
@ -29,21 +29,3 @@ 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,9 +1,5 @@
|
||||||
# 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/
|
||||||
|
|
||||||
|
|
21
contrib/example.go
Normal file
21
contrib/example.go
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
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