fix unix line endings
This commit is contained in:
parent
b53e0bb9c7
commit
c955b3ee3c
24 changed files with 1044 additions and 1044 deletions
|
|
@ -1,15 +1,15 @@
|
|||
package internal
|
||||
|
||||
import "net"
|
||||
|
||||
func ParseIP(s string) (net.IP, error) {
|
||||
var err error = nil
|
||||
ip := net.ParseIP(s)
|
||||
if ip == nil {
|
||||
err = &net.ParseError{
|
||||
Type: "IP address",
|
||||
Text: s,
|
||||
}
|
||||
}
|
||||
return ip, err
|
||||
}
|
||||
package internal
|
||||
|
||||
import "net"
|
||||
|
||||
func ParseIP(s string) (net.IP, error) {
|
||||
var err error = nil
|
||||
ip := net.ParseIP(s)
|
||||
if ip == nil {
|
||||
err = &net.ParseError{
|
||||
Type: "IP address",
|
||||
Text: s,
|
||||
}
|
||||
}
|
||||
return ip, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,35 +1,35 @@
|
|||
package internal
|
||||
|
||||
import (
|
||||
"net"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestParseIP(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
input string
|
||||
want net.IP
|
||||
wantErr bool
|
||||
}{
|
||||
{"localhost", "127.0.0.1", net.IPv4(127, 0, 0, 1), false},
|
||||
{"Private#1", "10.4.0.11", net.IPv4(10, 4, 0, 11), false},
|
||||
{"Private#2", "192.168.1.12", net.IPv4(192, 168, 1, 12), false},
|
||||
{"Public#1", "82.249.10.254", net.IPv4(82, 249, 10, 254), false},
|
||||
{"Public#2", "57.167.50.222", net.IPv4(57, 167, 50, 222), false},
|
||||
{"Invalid", "xx", nil, true},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got, err := ParseIP(tt.input)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("ParseIP() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
}
|
||||
if !reflect.DeepEqual(got, tt.want) {
|
||||
t.Errorf("ParseIP() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
package internal
|
||||
|
||||
import (
|
||||
"net"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestParseIP(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
input string
|
||||
want net.IP
|
||||
wantErr bool
|
||||
}{
|
||||
{"localhost", "127.0.0.1", net.IPv4(127, 0, 0, 1), false},
|
||||
{"Private#1", "10.4.0.11", net.IPv4(10, 4, 0, 11), false},
|
||||
{"Private#2", "192.168.1.12", net.IPv4(192, 168, 1, 12), false},
|
||||
{"Public#1", "82.249.10.254", net.IPv4(82, 249, 10, 254), false},
|
||||
{"Public#2", "57.167.50.222", net.IPv4(57, 167, 50, 222), false},
|
||||
{"Invalid", "xx", nil, true},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got, err := ParseIP(tt.input)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("ParseIP() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
}
|
||||
if !reflect.DeepEqual(got, tt.want) {
|
||||
t.Errorf("ParseIP() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue