Skip to content

Commit a9d7e71

Browse files
committed
docs: example outputs
1 parent e788a69 commit a9d7e71

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

opt_ids.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import (
99
// with corresponding ICMP sequence numbers.
1010
type optIDs struct {
1111
counter uint32
12-
m map[uint32]uint16
13-
mu sync.RWMutex
12+
m map[uint32]uint16
13+
mu sync.RWMutex
1414
}
1515

1616
func newOptIDs() *optIDs {

opts_test.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,18 @@ func TestNewOption(t *testing.T) {
3333
require.Equal(t, val, i)
3434
}
3535

36-
func ExamplePinger_Set() {
37-
p, _ := New(nil)
36+
func ExamplePinger_setGet() {
37+
p, err := New(nil)
38+
if err != nil {
39+
log.Panic(err)
40+
}
3841
if err := p.Set(TTL(1)); err != nil {
3942
log.Panic(err)
4043
}
41-
}
42-
43-
func ExamplePinger_Get() {
44-
p, _ := New(nil)
4544
ttl := TTL(0)
4645
if err := p.Get(ttl); err != nil {
4746
log.Panic(err)
4847
}
4948
fmt.Println(ttl.Get())
50-
// Output: 64
49+
// Output: 1
5150
}

ping_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func BenchmarkPinger(b *testing.B) {
6767
g.Go(func() error {
6868
return p.Listen(ctx)
6969
})
70-
defer func(){
70+
defer func() {
7171
cancel()
7272
if err := g.Wait(); !errors.Is(err, context.Canceled) {
7373
b.Fatal(err)
@@ -203,5 +203,6 @@ func ExamplePinger_PingNContextInterval() {
203203
fmt.Println(err)
204204
return
205205
}
206-
fmt.Printf("packet loss: %f, avg RTT: %s\n", float32(send-len(rs))/float32(send), rs.AvgRTT())
206+
fmt.Printf("packet loss: %.2f%%, avg RTT: %s\n",
207+
100*float32(send-len(rs))/float32(send), rs.AvgRTT())
207208
}

seq_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
func BenchmarkReserve(b *testing.B) {
1010
r := newReserve()
1111
ctx := context.Background()
12-
b.SetParallelism(2*math.MaxUint16)
12+
b.SetParallelism(2 * math.MaxUint16)
1313
b.RunParallel(func(pb *testing.PB) {
1414
for pb.Next() {
1515
seq, err := r.get(ctx)

0 commit comments

Comments
 (0)