-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathip_addr_example_test.go
More file actions
45 lines (36 loc) · 880 Bytes
/
ip_addr_example_test.go
File metadata and controls
45 lines (36 loc) · 880 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2020 Walter Scheper <walter.scheper@gmail.com>
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
package rapid_test
import (
"fmt"
"pgregory.net/rapid"
)
func ExampleIPv4() {
gen := rapid.IPv4()
for i := 0; i < 5; i++ {
addr := gen.Example(i)
fmt.Println(addr.String())
}
// Output:
// 0.23.24.7
// 100.146.0.0
// 0.222.65.1
// 1.49.104.14
// 11.56.0.83
}
func ExampleIPv6() {
gen := rapid.IPv6()
for i := 0; i < 5; i++ {
addr := gen.Example(i)
fmt.Println(addr.String())
}
// Output:
// 17:1807:e2c4:8210:7202:f4b2:a0e2:8dc
// 6492:0:fa37:b00:b5c3:4e6:6a01:c802
// de:4101:9f5:3:104:5dc:b600:905
// 131:680e:97ff:d200:ae1:4d00:2300:103
// b38:53:ff07:200:8c28:ee:ad00:1b
}