lint: fix all major issues
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
@@ -17,6 +17,7 @@ type httpProfile struct {
|
||||
}
|
||||
|
||||
var (
|
||||
// DefaultAddress for http profiler
|
||||
DefaultAddress = ":6060"
|
||||
)
|
||||
|
||||
@@ -60,7 +61,8 @@ func (h *httpProfile) String() string {
|
||||
return "http"
|
||||
}
|
||||
|
||||
func NewProfile(opts ...profile.Option) profile.Profile {
|
||||
// NewProfile returns new http profiler
|
||||
func NewProfile(opts ...profile.Option) profile.Profiler {
|
||||
mux := http.NewServeMux()
|
||||
|
||||
mux.HandleFunc("/debug/pprof/", pprof.Index)
|
||||
|
||||
20
profiler/noop.go
Normal file
20
profiler/noop.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package profiler
|
||||
|
||||
type noopProfiler struct{}
|
||||
|
||||
func (p *noopProfiler) Start() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *noopProfiler) Stop() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *noopProfiler) String() string {
|
||||
return "noop"
|
||||
}
|
||||
|
||||
// NewProfiler returns new noop profiler
|
||||
func NewProfiler(opts ...Option) Profiler {
|
||||
return &noopProfiler{}
|
||||
}
|
||||
@@ -111,12 +111,11 @@ func (p *profiler) String() string {
|
||||
return "pprof"
|
||||
}
|
||||
|
||||
func NewProfile(opts ...profile.Option) profile.Profile {
|
||||
var options profile.Options
|
||||
// NewProfile create new profiler
|
||||
func NewProfile(opts ...profile.Option) profile.Profiler {
|
||||
options := profile.Options{}
|
||||
for _, o := range opts {
|
||||
o(&options)
|
||||
}
|
||||
p := new(profiler)
|
||||
p.opts = options
|
||||
return p
|
||||
return &profiler{opts: options}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// Package profile is for profilers
|
||||
package profile
|
||||
// Package profiler is for profilers
|
||||
package profiler
|
||||
|
||||
type Profile interface {
|
||||
// Profiler interface
|
||||
type Profiler interface {
|
||||
// Start the profiler
|
||||
Start() error
|
||||
// Stop the profiler
|
||||
@@ -11,28 +12,17 @@ type Profile interface {
|
||||
}
|
||||
|
||||
var (
|
||||
DefaultProfile Profile = &NoopProfile{}
|
||||
// DefaultProfiler holds the default profiler
|
||||
DefaultProfiler Profiler = NewProfiler()
|
||||
)
|
||||
|
||||
type NoopProfile struct{}
|
||||
|
||||
func (p *NoopProfile) Start() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *NoopProfile) Stop() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *NoopProfile) String() string {
|
||||
return "noop"
|
||||
}
|
||||
|
||||
// Options holds the options for profiler
|
||||
type Options struct {
|
||||
// Name to use for the profile
|
||||
Name string
|
||||
}
|
||||
|
||||
// Option func signature
|
||||
type Option func(o *Options)
|
||||
|
||||
// Name of the profile
|
||||
|
||||
Reference in New Issue
Block a user