Skip to content

Commit 8443201

Browse files
committed
refactor: use reflect.TypeFor
Signed-off-by: dulanting <[email protected]>
1 parent 0740b18 commit 8443201

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

cmd/algofix/fix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ func expr(s string) ast.Expr {
750750
return x
751751
}
752752

753-
var posType = reflect.TypeOf(token.Pos(0))
753+
var posType = reflect.TypeFor[token.Pos]()
754754

755755
func killPos(v reflect.Value) {
756756
switch v.Kind() {

logging/telemetryspec/metric_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func TestAssembleBlockStatsString(t *testing.T) {
6868
partitiontest.PartitionTest(t)
6969

7070
var abs AssembleBlockStats
71-
localType := reflect.TypeOf(abs)
71+
localType := reflect.TypeFor[AssembleBlockStats]()
7272

7373
// Empty StateProofStats will not be reported. Set a filed to check it printed
7474
abs.StateProofStats.ProvenWeight = 1

protocol/codec_tester.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ type msgpMarshalUnmarshal interface {
4242
msgp.Unmarshaler
4343
}
4444

45-
var rawMsgpType = reflect.TypeOf(msgp.Raw{})
45+
var rawMsgpType = reflect.TypeFor[msgp.Raw]()
4646
var errSkipRawMsgpTesting = fmt.Errorf("skipping msgp.Raw serializing, since it won't be the same across go-codec and msgp")
4747

4848
func oneOf(n int) bool {

test/netperf-go/puppeteer/puppeteer.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,12 @@ func puppeteer(channel, jsonFile string) error {
121121

122122
func printMetrics(puppets []*puppet) {
123123
totalWidth := 0
124-
header := ""
124+
var header strings.Builder
125125
for _, puppet := range puppets {
126126
totalWidth += len(puppet.recipeName) + 3
127-
header += "| " + puppet.recipeName + " "
127+
header.WriteString("| " + puppet.recipeName + " ")
128128
}
129-
header += "|"
129+
header.WriteString("|")
130130
totalWidth++
131131

132132
maxMetricNameWidth := 0
@@ -145,7 +145,7 @@ func printMetrics(puppets []*puppet) {
145145
}
146146
sort.Strings(metricNames)
147147

148-
fmt.Printf("%s%s\n%s\n", strings.Repeat(" ", maxMetricNameWidth+1), header, strings.Repeat("-", totalWidth+maxMetricNameWidth+1))
148+
fmt.Printf("%s%s\n%s\n", strings.Repeat(" ", maxMetricNameWidth+1), header.String(), strings.Repeat("-", totalWidth+maxMetricNameWidth+1))
149149

150150
for _, metricName := range metricNames {
151151
line := fmt.Sprintf("%s%s", metricName, strings.Repeat(" ", maxMetricNameWidth-len(metricName)+1))

0 commit comments

Comments
 (0)