File tree 6 files changed +68
-8
lines changed
6 files changed +68
-8
lines changed Original file line number Diff line number Diff line change @@ -2243,23 +2243,37 @@ linters-settings:
2243
2243
# still required to have `t.Parallel`, but subtests are allowed to skip it.
2244
2244
# Default: false
2245
2245
ignore-missing-subtests : true
2246
-
2247
2246
perfsprint :
2247
+ # Enable/disable optimization of integer formatting.
2248
+ # Default: true
2249
+ integer-format : false
2248
2250
# Optimizes even if it requires an int or uint type cast.
2249
2251
# Default: true
2250
2252
int-conversion : false
2253
+ # Enable/disable optimization of error formatting.
2254
+ # Default: true
2255
+ error-format : false
2251
2256
# Optimizes into `err.Error()` even if it is only equivalent for non-nil errors.
2252
2257
# Default: false
2253
2258
err-error : true
2254
2259
# Optimizes `fmt.Errorf`.
2255
2260
# Default: true
2256
2261
errorf : false
2262
+ # Enable/disable optimization of string formatting.
2263
+ # Default: true
2264
+ string-format : false
2257
2265
# Optimizes `fmt.Sprintf` with only one argument.
2258
2266
# Default: true
2259
2267
sprintf1 : false
2260
2268
# Optimizes into strings concatenation.
2261
2269
# Default: true
2262
2270
strconcat : false
2271
+ # Enable/disable optimization of bool formatting.
2272
+ # Default: true
2273
+ bool-format : false
2274
+ # Enable/disable optimization of hex formatting.
2275
+ # Default: true
2276
+ hex-format : false
2263
2277
2264
2278
prealloc :
2265
2279
# IMPORTANT: we don't recommend using this linter before doing performance profiling.
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ require (
29
29
github.com/breml/errchkjson v0.4.0
30
30
github.com/butuzov/ireturn v0.3.1
31
31
github.com/butuzov/mirror v1.3.0
32
- github.com/catenacyber/perfsprint v0.7.1
32
+ github.com/catenacyber/perfsprint v0.8.0
33
33
github.com/charithe/durationcheck v0.0.10
34
34
github.com/ckaznocha/intrange v0.3.0
35
35
github.com/curioswitch/go-reassign v0.3.0
Original file line number Diff line number Diff line change 2472
2472
"type" : " object" ,
2473
2473
"additionalProperties" : false ,
2474
2474
"properties" : {
2475
+ "integer-format" : {
2476
+ "description" : " Enable/disable optimization of integer formatting." ,
2477
+ "type" : " boolean" ,
2478
+ "default" : true
2479
+ },
2475
2480
"int-conversion" : {
2476
2481
"description" : " Optimizes even if it requires an int or uint type cast." ,
2477
2482
"type" : " boolean" ,
2478
2483
"default" : true
2479
2484
},
2485
+ "error-format" : {
2486
+ "description" : " Enable/disable optimization of error formatting." ,
2487
+ "type" : " boolean" ,
2488
+ "default" : true
2489
+ },
2480
2490
"err-error" : {
2481
2491
"description" : " Optimizes into `err.Error()` even if it is only equivalent for non-nil errors." ,
2482
2492
"type" : " boolean" ,
2487
2497
"type" : " boolean" ,
2488
2498
"default" : true
2489
2499
},
2500
+ "string-format" : {
2501
+ "description" : " Enable/disable optimization of string formatting." ,
2502
+ "type" : " boolean" ,
2503
+ "default" : true
2504
+ },
2490
2505
"sprintf1" : {
2491
2506
"description" : " Optimizes `fmt.Sprintf` with only one argument." ,
2492
2507
"type" : " boolean" ,
2496
2511
"description" : " Optimizes into strings concatenation." ,
2497
2512
"type" : " boolean" ,
2498
2513
"default" : true
2514
+ },
2515
+ "bool-format" : {
2516
+ "description" : " Enable/disable optimization of bool formatting." ,
2517
+ "type" : " boolean" ,
2518
+ "default" : true
2519
+ },
2520
+ "hex-format" : {
2521
+ "description" : " Enable/disable optimization of hex formatting." ,
2522
+ "type" : " boolean" ,
2523
+ "default" : true
2499
2524
}
2500
2525
}
2501
2526
},
Original file line number Diff line number Diff line change @@ -126,11 +126,16 @@ var defaultLintersSettings = LintersSettings{
126
126
AllowUnused : false ,
127
127
},
128
128
PerfSprint : PerfSprintSettings {
129
+ IntegerFormat : true ,
129
130
IntConversion : true ,
131
+ ErrorFormat : true ,
130
132
ErrError : false ,
131
133
ErrorF : true ,
134
+ StringFormat : true ,
132
135
SprintF1 : true ,
133
136
StrConcat : true ,
137
+ BoolFormat : true ,
138
+ HexFormat : true ,
134
139
},
135
140
Prealloc : PreallocSettings {
136
141
Simple : true ,
@@ -791,11 +796,19 @@ type ParallelTestSettings struct {
791
796
}
792
797
793
798
type PerfSprintSettings struct {
799
+ IntegerFormat bool `mapstructure:"integer-format"`
794
800
IntConversion bool `mapstructure:"int-conversion"`
795
- ErrError bool `mapstructure:"err-error"`
796
- ErrorF bool `mapstructure:"errorf"`
797
- SprintF1 bool `mapstructure:"sprintf1"`
798
- StrConcat bool `mapstructure:"strconcat"`
801
+
802
+ ErrorFormat bool `mapstructure:"error-format"`
803
+ ErrError bool `mapstructure:"err-error"`
804
+ ErrorF bool `mapstructure:"errorf"`
805
+
806
+ StringFormat bool `mapstructure:"string-format"`
807
+ SprintF1 bool `mapstructure:"sprintf1"`
808
+ StrConcat bool `mapstructure:"strconcat"`
809
+
810
+ BoolFormat bool `mapstructure:"bool-format"`
811
+ HexFormat bool `mapstructure:"hex-format"`
799
812
}
800
813
801
814
type PreallocSettings struct {
Original file line number Diff line number Diff line change @@ -16,11 +16,19 @@ func New(settings *config.PerfSprintSettings) *goanalysis.Linter {
16
16
}
17
17
18
18
if settings != nil {
19
+ cfg [a .Name ]["integer-format" ] = settings .IntegerFormat
19
20
cfg [a .Name ]["int-conversion" ] = settings .IntConversion
21
+
22
+ cfg [a .Name ]["error-format" ] = settings .ErrorFormat
20
23
cfg [a .Name ]["err-error" ] = settings .ErrError
21
24
cfg [a .Name ]["errorf" ] = settings .ErrorF
25
+
26
+ cfg [a .Name ]["string-format" ] = settings .StringFormat
22
27
cfg [a .Name ]["sprintf1" ] = settings .SprintF1
23
28
cfg [a .Name ]["strconcat" ] = settings .StrConcat
29
+
30
+ cfg [a .Name ]["bool-format" ] = settings .BoolFormat
31
+ cfg [a .Name ]["hex-format" ] = settings .HexFormat
24
32
}
25
33
26
34
return goanalysis .NewLinter (
You can’t perform that action at this time.
0 commit comments