Skip to content

Commit

Permalink
better example
Browse files Browse the repository at this point in the history
  • Loading branch information
gaissmai committed Dec 22, 2024
1 parent 1ac8eb0 commit 6b43dae
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var input = []struct {
{p("::/0"), a("2001:db8::1")},
{p("10.0.1.0/24"), a("10.0.0.0")},
{p("169.254.0.0/16"), a("10.0.0.0")},
{p("2000::/3"), a("2001:db8::1")},
{p("2000::/3"), a("2000::")},
{p("2001:db8::/32"), a("2001:db8::1")},
{p("127.0.0.0/8"), a("127.0.0.1")},
{p("127.0.0.1/32"), a("127.0.0.1")},
Expand All @@ -47,15 +47,15 @@ func ExampleTable_Lookup() {

ip := a("42.0.0.0")
value, ok := rtbl.Lookup(ip)
fmt.Printf("Lookup: %-20v value: %11v, ok: %v\n", ip, value, ok)
fmt.Printf("Lookup: %-20v next-hop: %11v, ok: %v\n", ip, value, ok)

ip = a("10.0.1.17")
value, ok = rtbl.Lookup(ip)
fmt.Printf("Lookup: %-20v value: %11v, ok: %v\n", ip, value, ok)
fmt.Printf("Lookup: %-20v next-hop: %11v, ok: %v\n", ip, value, ok)

ip = a("2001:7c0:3100:1::111")
value, ok = rtbl.Lookup(ip)
fmt.Printf("Lookup: %-20v value: %11v, ok: %v\n", ip, value, ok)
fmt.Printf("Lookup: %-20v next-hop: %11v, ok: %v\n", ip, value, ok)

// Output:
// ▼
Expand All @@ -71,13 +71,13 @@ func ExampleTable_Lookup() {
// ▼
// └─ ::/0 (2001:db8::1)
// ├─ ::1/128 (::1%lo)
// ├─ 2000::/3 (2001:db8::1)
// ├─ 2000::/3 (2000::)
// │ └─ 2001:db8::/32 (2001:db8::1)
// └─ fe80::/10 (::1%eth0)
//
// Lookup: 42.0.0.0 value: invalid IP, ok: false
// Lookup: 10.0.1.17 value: 10.0.0.0, ok: true
// Lookup: 2001:7c0:3100:1::111 value: 2001:db8::1, ok: true
// Lookup: 42.0.0.0 next-hop: invalid IP, ok: false
// Lookup: 10.0.1.17 next-hop: 10.0.0.0, ok: true
// Lookup: 2001:7c0:3100:1::111 next-hop: 2000::, ok: true
}

func ExampleTable_AllSorted4_callback() {
Expand Down

0 comments on commit 6b43dae

Please sign in to comment.