shad-go/iprange/example_test.go

26 lines
423 B
Go
Raw Normal View History

2022-04-14 01:36:15 +00:00
package iprange_test
import (
"fmt"
"log"
2023-10-02 19:32:41 +00:00
"gitlab.com/manytask/itmo-go/private/iprange"
2022-04-14 01:36:15 +00:00
)
func ExampleParseList() {
list, err := iprange.ParseList("10.0.0.1, 10.0.0.5-10, 192.168.1.*, 192.168.10.0/24")
if err != nil {
log.Fatal(err)
}
for _, i := range list {
fmt.Println(i)
}
// Output:
// {10.0.0.1 10.0.0.1}
// {10.0.0.5 10.0.0.10}
// {192.168.1.0 192.168.1.255}
// {192.168.10.0 192.168.10.255}
}