@@ -58,9 +58,9 @@ type Config struct {
58
58
// Default is false.
59
59
Disable bool
60
60
61
- // ProfileMode is one of cpu, goroutine, threadcreate, heap, allocs, block, mutex.
61
+ // Mode is one of cpu, goroutine, threadcreate, heap, allocs, block, mutex.
62
62
// Default is empty string and is treated as cpu.
63
- ProfileMode string
63
+ Mode string
64
64
65
65
// OutputDir where profile must be saved.
66
66
// Default is empty string and is treated as ".".
@@ -89,16 +89,16 @@ type Config struct {
89
89
90
90
// newProfiler creates new profiler based on a config.
91
91
func newProfiler (cfg Config ) (* Profiler , error ) {
92
- if cfg .ProfileMode == "" {
93
- cfg .ProfileMode = CpuMode
92
+ if cfg .Mode == "" {
93
+ cfg .Mode = CpuMode
94
94
}
95
95
96
- switch cfg .ProfileMode {
96
+ switch cfg .Mode {
97
97
case CpuMode , TraceMode , HeapMode , AllocsMode , MutexMode ,
98
98
BlockMode , ThreadCreateMode , GoroutineMode , FgprofMode :
99
99
// pass
100
100
default :
101
- return nil , fmt .Errorf ("unknown profile mode: %s" , cfg .ProfileMode )
101
+ return nil , fmt .Errorf ("unknown profile mode: %s" , cfg .Mode )
102
102
}
103
103
104
104
if cfg .OutputDir == "" {
@@ -119,7 +119,7 @@ func newProfiler(cfg Config) (*Profiler, error) {
119
119
prefix = cfg .FilePrefix + "_"
120
120
}
121
121
now := time .Now ().Format ("20060102-15:04:05" )
122
- filename := fmt .Sprintf ("%s%s_%s.pprof" , prefix , cfg .ProfileMode , now )
122
+ filename := fmt .Sprintf ("%s%s_%s.pprof" , prefix , cfg .Mode , now )
123
123
124
124
if err := os .MkdirAll (cfg .OutputDir , 0777 ); err != nil {
125
125
return nil , err
@@ -131,7 +131,7 @@ func newProfiler(cfg Config) (*Profiler, error) {
131
131
132
132
p := & Profiler {
133
133
cfg : cfg ,
134
- mode : cfg .ProfileMode ,
134
+ mode : cfg .Mode ,
135
135
output : output ,
136
136
}
137
137
return p , nil
0 commit comments