net

package
v1.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 15, 2017 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package net implements a set of net types that are extensions to the built-in net package. The extensions provide additional function such as JSON marshaling and unmarshaling.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseCIDR

func ParseCIDR(c string) (*IP, *IPNet, error)

Types

type IP

type IP struct {
	net.IP
}

Sub class net.IP so that we can add JSON marshalling and unmarshalling.

func (IP) MarshalJSON

func (i IP) MarshalJSON() ([]byte, error)

MarshalJSON interface for an IP

func (*IP) Network added in v1.1.1

func (i *IP) Network() *IPNet

Network returns the IP address as a fully masked IPNet type.

func (*IP) UnmarshalJSON

func (i *IP) UnmarshalJSON(b []byte) error

UnmarshalJSON interface for an IP

func (IP) Version

func (i IP) Version() int

Version returns the IP version for an IP, or 0 if the IP is not valid.

type IPNet

type IPNet struct {
	net.IPNet
}

Sub class net.IPNet so that we can add JSON marshalling and unmarshalling.

func (IPNet) MarshalJSON

func (i IPNet) MarshalJSON() ([]byte, error)

MarshalJSON interface for an IPNet

func (*IPNet) Network added in v1.1.1

func (i *IPNet) Network() *IPNet

Network returns the masked IP network.

func (IPNet) String

func (i IPNet) String() string

String returns a friendly name for the network. The standard net package implements String() on the pointer, which means it will not be invoked on a struct type, so we re-implement on the struct type.

func (*IPNet) UnmarshalJSON

func (i *IPNet) UnmarshalJSON(b []byte) error

UnmarshalJSON interface for an IPNet

func (*IPNet) Version

func (i *IPNet) Version() int

Version returns the IP version for an IPNet, or 0 if not a valid IP net.

type MAC

type MAC struct {
	net.HardwareAddr
}

Sub class net.HardwareAddr so that we can add JSON marshalling and unmarshalling.

func (MAC) MarshalJSON

func (m MAC) MarshalJSON() ([]byte, error)

MarshalJSON interface for a MAC

func (*MAC) UnmarshalJSON

func (m *MAC) UnmarshalJSON(b []byte) error

UnmarshalJSON interface for a MAC

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL