File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed
Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -14,8 +14,8 @@ import (
1414
1515type IP struct {
1616 net.IP
17- Version int8
18- PrefixLength int
17+ Version uint8 // 4 and 6, 0 == unset
18+ PrefixLength int // -1 = unset
1919}
2020
2121func ParseIP (s string ) IP {
@@ -43,8 +43,8 @@ func ParseIP(s string) IP {
4343 }
4444}
4545
46- func ipVersionMask (ip net.IP , mask int ) (int8 , int ) {
47- var version int8
46+ func ipVersionMask (ip net.IP , mask int ) (uint8 , int ) {
47+ var version uint8
4848 if ip .To4 () != nil {
4949 version = 4
5050 if mask == - 1 {
@@ -276,7 +276,7 @@ func (i IP) Cmp(other IP) int {
276276}
277277
278278func (i IP ) CIDR () string {
279- return i .IP .String () + "/" + strconv .Itoa (i .PrefixLength )
279+ return i .IP .String () + "/" + strconv .Itoa (int ( i .PrefixLength ) )
280280}
281281
282282func (i IP ) Marshal () ([]byte , error ) {
@@ -296,7 +296,7 @@ func UnmarshalIP(data []byte) (*IP, error) {
296296 return nil , errors .New ("incorrect storage of IP value, expected at least 3 bytes" )
297297 }
298298 return & IP {
299- Version : int8 (data [0 ]),
299+ Version : uint8 (data [0 ]),
300300 PrefixLength : int (bytes2int (data [1 :3 ])),
301301 IP : data [3 :],
302302 }, nil
You can’t perform that action at this time.
0 commit comments