-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e639f30
commit 0af7580
Showing
8 changed files
with
489 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
--- | ||
run: | ||
tests: false | ||
linters-settings: | ||
dupl: | ||
threshold: 100 | ||
funlen: | ||
lines: 100 | ||
statements: 50 | ||
goconst: | ||
min-len: 2 | ||
min-occurrences: 2 | ||
gocritic: | ||
enabled-tags: | ||
- diagnostic | ||
- experimental | ||
- opinionated | ||
- performance | ||
- style | ||
disabled-checks: | ||
- hugeParam | ||
gocyclo: | ||
min-complexity: 15 | ||
revive: | ||
confidence: 0.8 | ||
lll: | ||
line-length: 140 | ||
misspell: | ||
locale: US | ||
nolintlint: | ||
require-explanation: true | ||
allow-no-explanation: | ||
- gocognit | ||
- funlen | ||
- gocyclo | ||
|
||
linters: | ||
disable-all: true | ||
enable: | ||
- bodyclose | ||
- dogsled | ||
- dupl | ||
- errcheck | ||
- funlen | ||
- nolintlint | ||
- gochecknoglobals | ||
- gochecknoinits | ||
- gocognit | ||
- goconst | ||
- gocritic | ||
- gocyclo | ||
- gofmt | ||
- goimports | ||
- revive | ||
- goprintffuncname | ||
- gosec | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
- misspell | ||
- nakedret | ||
- prealloc | ||
- protogetter | ||
- rowserrcheck | ||
- copyloopvar | ||
- staticcheck | ||
- stylecheck | ||
- sqlclosecheck | ||
- typecheck | ||
- unconvert | ||
- unparam | ||
- unused | ||
- whitespace | ||
- wsl | ||
|
||
issues: | ||
exclude: | ||
# Very commonly not checked. | ||
- 'Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked' | ||
- 'G104:.*' | ||
- 'exported method (.*\.MarshalJSON|.*\.UnmarshalJSON|.*\.MarshalText|.*\.UnmarshalText|.*\.LogValue|.*\.MarshalLogObject) should have comment or be unexported' | ||
- 'shadow: declaration of "err" shadows declaration.*' | ||
max-same-issues: 0 | ||
exclude-use-default: false | ||
exclude-dirs: | ||
- .github | ||
- build | ||
- web | ||
- .go | ||
- vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
module github.com/postfinance/profiler | ||
|
||
go 1.15 | ||
go 1.23 | ||
|
||
require github.com/stretchr/testify v1.6.1 | ||
|
||
require ( | ||
github.com/davecgh/go-spew v1.1.0 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package profiler | ||
|
||
import ( | ||
"os" | ||
"time" | ||
) | ||
|
||
// Option is a Profiler functional option | ||
type Option func(*Profiler) | ||
|
||
// WithSignal sets the signal to activate the pprof handler | ||
func WithSignal(s os.Signal) Option { | ||
return func(p *Profiler) { | ||
p.signal = s | ||
} | ||
} | ||
|
||
// WithAddress sets the listen address of the pprof handler | ||
func WithAddress(address string) Option { | ||
return func(p *Profiler) { | ||
p.address = address | ||
} | ||
} | ||
|
||
// WithTimeout sets the timeout after the pprof handler will be shutdown | ||
func WithTimeout(timeout time.Duration) Option { | ||
return func(p *Profiler) { | ||
p.timeout = timeout | ||
} | ||
} | ||
|
||
// WithEventHandler registers a custom event handler | ||
func WithEventHandler(evt EventHandler) Option { | ||
return func(p *Profiler) { | ||
p.evt = evt | ||
} | ||
} | ||
|
||
// WithHooks registers the Profiler hooks | ||
func WithHooks(hooks ...Hooker) Option { | ||
return func(p *Profiler) { | ||
p.hooks = append(p.hooks, hooks...) | ||
} | ||
} |
Oops, something went wrong.