Documentation
¶
Overview ¶
Package inettree implements the tree.Interface for inet.Block
Example (Usage) ¶
package main import ( "fmt" "github.com/gaissmai/go-inet/v2/inet" "github.com/gaissmai/go-inet/v2/inettree" "github.com/gaissmai/go-inet/v2/tree" ) var iana = map[string]string{ "::/8": "Reserved by IETF [RFC3513][RFC4291]", "100::/8": "Reserved by IETF [RFC3513][RFC4291]", "200::/7": "Reserved by IETF [RFC4048]", "400::/6": "Reserved by IETF [RFC3513][RFC4291]", "800::/5": "Reserved by IETF [RFC3513][RFC4291]", "1000::/4": "Reserved by IETF [RFC3513][RFC4291]", "2000::/3": "Global Unicast [RFC3513][RFC4291]", "2000::/4": "", "3000::/4": "FREE", "4000::/3": "Reserved by IETF [RFC3513][RFC4291]", "6000::/3": "Reserved by IETF [RFC3513][RFC4291]", // force duplicate error "2000::0000/3": "Global Unicast [RFC3513][RFC4291]", } func main() { bs := make([]tree.Interface, 0, len(iana)) for k, text := range iana { block, err := inet.ParseBlock(k) if err != nil { panic(err) } if text != "" { text = block.String() + " ... " + text } bs = append(bs, inettree.Item{block, text}) } t, err := tree.New(bs) if err != nil { fmt.Println("ERROR:", err) fmt.Printf("dups: %v\n\n", t.Duplicates()) } fmt.Println(t) }
Output: ERROR: some items are duplicate dups: [2000::/3 ... Global Unicast [RFC3513][RFC4291]] ▼ ├─ ::/8 ... Reserved by IETF [RFC3513][RFC4291] ├─ 100::/8 ... Reserved by IETF [RFC3513][RFC4291] ├─ 200::/7 ... Reserved by IETF [RFC4048] ├─ 400::/6 ... Reserved by IETF [RFC3513][RFC4291] ├─ 800::/5 ... Reserved by IETF [RFC3513][RFC4291] ├─ 1000::/4 ... Reserved by IETF [RFC3513][RFC4291] ├─ 2000::/3 ... Global Unicast [RFC3513][RFC4291] │ ├─ 2000::/4 │ └─ 3000::/4 ... FREE ├─ 4000::/3 ... Reserved by IETF [RFC3513][RFC4291] └─ 6000::/3 ... Reserved by IETF [RFC3513][RFC4291]
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Item ¶
type Item struct { // the augmented Block inet.Block // augment Block with additional text, see example Text string }
Item augments inet.Block, implementing the tree.Interface
Click to show internal directories.
Click to hide internal directories.