package netutil

import "github.com/teamwork/utils/netutil"

Index

Functions

func RemovePort

func RemovePort(host string) string

RemovePort removes the "port" part of an hostname.

Types

type IP

type IP net.IP

IP is a special wrapped type of net.IP

func (IP) Eq

func (ip IP) Eq(cmp net.IP) bool

Eq will return if the IP is less than to the given IP

func (IP) Gt

func (ip IP) Gt(start net.IP) bool

Gt will return if the IP is greater than to the given IP

func (IP) Gte

func (ip IP) Gte(start net.IP) bool

Gte will return if the IP is greater than or equal to the given IP

func (IP) InRange

func (ip IP) InRange(start, end net.IP) bool

InRange will return if the IP is within the given range of addresses

func (IP) Lt

func (ip IP) Lt(end net.IP) bool

Lt will return if the IP is less than to the given IP

func (IP) Lte

func (ip IP) Lte(end net.IP) bool

Lte will return if the IP is less than or equal to the given IP

func (*IP) MarshalJSON

func (ip *IP) MarshalJSON() ([]byte, error)

MarshalJSON specifies how the IP should be returned in the JSON. For this we can just utilise the existing custom marshaling on the net.IP object as it already does what we need.

func (*IP) Scan

func (ip *IP) Scan(value interface{}) error

Scan will return the IP from the database

func (IP) String

func (ip IP) String() string

String returns the IP as a string

func (*IP) UnmarshalJSON

func (ip *IP) UnmarshalJSON(data []byte) error

UnmarshalJSON specifies how the IP should be parsed from the JSON. For this we can just utilise the existing custom marshaling on the net.IP object as it already does what we need.

func (IP) Value

func (ip IP) Value() (driver.Value, error)

Value will get the value for storing in SQL

Source Files

ip.go netutil.go

Version
v1.0.0 (latest)
Published
Mar 14, 2022
Platform
darwin/amd64
Imports
5 packages
Last checked
1 hour ago

Tools for package owners.