Add support for net.IP

This commit is contained in:
Federico G. Schwindt
2021-05-13 15:00:14 +01:00
committed by Ron Evans
parent 95e4dcfb53
commit b20905da13
6 changed files with 974 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
// The following is copied from Go 1.16 official implementation.
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package net
// A ParseError is the error type of literal network address parsers.
type ParseError struct {
// Type is the type of string that was expected, such as
// "IP address", "CIDR address".
Type string
// Text is the malformed text string.
Text string
}
func (e *ParseError) Error() string { return "invalid " + e.Type + ": " + e.Text }
type AddrError struct {
Err string
Addr string
}
func (e *AddrError) Error() string {
if e == nil {
return "<nil>"
}
s := e.Err
if e.Addr != "" {
s = "address " + e.Addr + ": " + s
}
return s
}
func (e *AddrError) Timeout() bool { return false }
func (e *AddrError) Temporary() bool { return false }