}
func TestWithValueChecksKey(t *testing.T) {
- panicVal := recoveredValue(func() { WithValue(Background(), []byte("foo"), "bar") })
+ panicVal := recoveredValue(func() { _ = WithValue(Background(), []byte("foo"), "bar") })
if panicVal == nil {
t.Error("expected panic")
}
- panicVal = recoveredValue(func() { WithValue(Background(), nil, "bar") })
+ panicVal = recoveredValue(func() { _ = WithValue(Background(), nil, "bar") })
if got, want := fmt.Sprint(panicVal), "nil key"; got != want {
t.Errorf("panic = %q; want %q", got, want)
}
}
func TestInvalidDerivedFail(t *testing.T) {
- panicVal := recoveredValue(func() { WithCancel(nil) })
+ panicVal := recoveredValue(func() { _, _ = WithCancel(nil) })
if panicVal == nil {
t.Error("expected panic")
}
- panicVal = recoveredValue(func() { WithDeadline(nil, time.Now().Add(shortDuration)) })
+ panicVal = recoveredValue(func() { _, _ = WithDeadline(nil, time.Now().Add(shortDuration)) })
if panicVal == nil {
t.Error("expected panic")
}
- panicVal = recoveredValue(func() { WithValue(nil, "foo", "bar") })
+ panicVal = recoveredValue(func() { _ = WithValue(nil, "foo", "bar") })
if panicVal == nil {
t.Error("expected panic")
}
func BenchmarkSprintfPadding(b *testing.B) {
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
- Sprintf("%16f", 1.0)
+ _ = Sprintf("%16f", 1.0)
}
})
}
func BenchmarkSprintfEmpty(b *testing.B) {
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
- Sprintf("")
+ _ = Sprintf("")
}
})
}
func BenchmarkSprintfString(b *testing.B) {
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
- Sprintf("%s", "hello")
+ _ = Sprintf("%s", "hello")
}
})
}
func BenchmarkSprintfTruncateString(b *testing.B) {
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
- Sprintf("%.3s", "日本語日本語日本語日本語")
+ _ = Sprintf("%.3s", "日本語日本語日本語日本語")
}
})
}
var bytes any = []byte("日本語日本語日本語日本語")
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
- Sprintf("%.3s", bytes)
+ _ = Sprintf("%.3s", bytes)
}
})
}
func BenchmarkSprintfSlowParsingPath(b *testing.B) {
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
- Sprintf("%.v", nil)
+ _ = Sprintf("%.v", nil)
}
})
}
func BenchmarkSprintfQuoteString(b *testing.B) {
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
- Sprintf("%q", "日本語日本語日本語")
+ _ = Sprintf("%q", "日本語日本語日本語")
}
})
}
func BenchmarkSprintfInt(b *testing.B) {
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
- Sprintf("%d", 5)
+ _ = Sprintf("%d", 5)
}
})
}
func BenchmarkSprintfIntInt(b *testing.B) {
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
- Sprintf("%d %d", 5, 6)
+ _ = Sprintf("%d %d", 5, 6)
}
})
}
func BenchmarkSprintfPrefixedInt(b *testing.B) {
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
- Sprintf("This is some meaningless prefix text that needs to be scanned %d", 6)
+ _ = Sprintf("This is some meaningless prefix text that needs to be scanned %d", 6)
}
})
}
func BenchmarkSprintfFloat(b *testing.B) {
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
- Sprintf("%g", 5.23184)
+ _ = Sprintf("%g", 5.23184)
}
})
}
func BenchmarkSprintfComplex(b *testing.B) {
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
- Sprintf("%f", 5.23184+5.23184i)
+ _ = Sprintf("%f", 5.23184+5.23184i)
}
})
}
func BenchmarkSprintfBoolean(b *testing.B) {
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
- Sprintf("%t", true)
+ _ = Sprintf("%t", true)
}
})
}
func BenchmarkSprintfHexString(b *testing.B) {
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
- Sprintf("% #x", "0123456789abcdef")
+ _ = Sprintf("% #x", "0123456789abcdef")
}
})
}
data := []byte("0123456789abcdef")
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
- Sprintf("% #x", data)
+ _ = Sprintf("% #x", data)
}
})
}
data := []byte("0123456789abcdef")
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
- Sprintf("%v", data)
+ _ = Sprintf("%v", data)
}
})
}
stringer := I(12345)
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
- Sprintf("%v", stringer)
+ _ = Sprintf("%v", stringer)
}
})
}
s := &[]any{SI{12345}, map[int]string{0: "hello"}}
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
- Sprintf("%#v", s)
+ _ = Sprintf("%#v", s)
}
})
}
desc string
fn func()
}{
- {0, `Sprintf("")`, func() { Sprintf("") }},
- {1, `Sprintf("xxx")`, func() { Sprintf("xxx") }},
- {0, `Sprintf("%x")`, func() { Sprintf("%x", 7) }},
- {1, `Sprintf("%x")`, func() { Sprintf("%x", 1<<16) }},
- {3, `Sprintf("%80000s")`, func() { Sprintf("%80000s", "hello") }}, // large buffer (>64KB)
- {1, `Sprintf("%s")`, func() { Sprintf("%s", "hello") }},
- {1, `Sprintf("%x %x")`, func() { Sprintf("%x %x", 7, 112) }},
- {1, `Sprintf("%g")`, func() { Sprintf("%g", float32(3.14159)) }},
+ {0, `Sprintf("")`, func() { _ = Sprintf("") }},
+ {1, `Sprintf("xxx")`, func() { _ = Sprintf("xxx") }},
+ {0, `Sprintf("%x")`, func() { _ = Sprintf("%x", 7) }},
+ {1, `Sprintf("%x")`, func() { _ = Sprintf("%x", 1<<16) }},
+ {3, `Sprintf("%80000s")`, func() { _ = Sprintf("%80000s", "hello") }}, // large buffer (>64KB)
+ {1, `Sprintf("%s")`, func() { _ = Sprintf("%s", "hello") }},
+ {1, `Sprintf("%x %x")`, func() { _ = Sprintf("%x %x", 7, 112) }},
+ {1, `Sprintf("%g")`, func() { _ = Sprintf("%g", float32(3.14159)) }},
{0, `Fprintf(buf, "%s")`, func() { mallocBuf.Reset(); Fprintf(&mallocBuf, "%s", "hello") }},
{0, `Fprintf(buf, "%x")`, func() { mallocBuf.Reset(); Fprintf(&mallocBuf, "%x", 7) }},
{0, `Fprintf(buf, "%x")`, func() { mallocBuf.Reset(); Fprintf(&mallocBuf, "%x", 1<<16) }},
func TestBadVerbRecursion(t *testing.T) {
failed := false
r := &Recur{3, &failed}
- Sprintf("recur@%p value: %d\n", &r, r.i)
+ _ = Sprintf("recur@%p value: %d\n", &r, r.i)
if failed {
t.Error("fail with pointer")
}
failed = false
r = &Recur{4, &failed}
- Sprintf("recur@%p, value: %d\n", r, r.i)
+ _ = Sprintf("recur@%p, value: %d\n", r, r.i)
if failed {
t.Error("fail with value")
}