MCPcopy Create free account
hub / github.com/deroproject/derohe / ParseIP

Function ParseIP

p2p/controller.go:778–790  ·  view source on GitHub ↗
(s string)

Source from the content-addressed store, hash-verified

776}
777
778func ParseIP(s string) (string, error) {
779 ip, _, err := net.SplitHostPort(s)
780 if err == nil {
781 return ip, nil
782 }
783
784 ip2 := net.ParseIP(s)
785 if ip2 == nil {
786 return "", fmt.Errorf("invalid IP")
787 }
788
789 return ip2.String(), nil
790}
791
792func ParseIPNoError(s string) string {
793 ip, _ := ParseIP(s)

Callers 1

ParseIPNoErrorFunction · 0.85

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected