net

package
v0.0.55 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetNativeEndian

func GetNativeEndian() binary.ByteOrder

GetNativeEndian gets byte order for the current system.

func Htonl

func Htonl(i uint32) uint32

Htonl convert uint32 from host byte order to network byte order. Network byte order is BigEndian.

func Htons

func Htons(i uint16) uint16

Htons convert uint16 from host byte order to network byte order. Network byte order is BigEndian.

func IPv4StrToU32

func IPv4StrToU32(s string) (ip uint32)

IPv4StrToU32 converts IPv4 string to uint32 in host byte order.

func IPv4ToU32

func IPv4ToU32(ip net.IP) uint32

IPv4ToU32 convert ipv4(a.b.c.d) to uint32 in host byte order.

func IsLittleEndian

func IsLittleEndian() bool

IsLittleEndian determines whether the host byte order is little endian.

func IsReservedIP

func IsReservedIP(ip string) int

IsReservedIP reports whether ip is private. Support ipv4/ipv6, refer rfc6890. Return <0 ip is invalid, =0 ip is public, >0 ip is private.

func Ntohl

func Ntohl(i uint32) uint32

Ntohl converts uint32 from network byte order to host byte order.

func Ntohs

func Ntohs(i uint16) uint16

Ntohs converts uint16 from network byte order to host byte order.

func QueryGetParam

func QueryGetParam(query, key string) (string, error)

QueryGetParam gets the specified key parameter from query string. The input is encoded query values without '?' and key is parameter name. E.g. if query string is "a=dog&b=tiger" and key is "a" will return dog.

func QueryGetParams

func QueryGetParams(query, key string) ([]string, error)

QueryGetParams gets the specified key parameters from query string. Rawquery is encoded query values without '?' and key is parameter name. E.g. if query is "a=dog&a=cat&b=tiger" and key is "a" QueryGetParams will return [dog cat]

func RawURLAddParam

func RawURLAddParam(raw, key, value string) (string, error)

RawURLAddParam adds query parameter to raw url. E.g. if rawURL=http://www.aspxfans.com:8080/news/index.asp?boardID=520&page=1&page=2#name and key=page value=3 will get http://www.aspxfans.com:8080/news/index.asp?boardID=520&page=1&page=2&page=3#name.

func RawURLAddParams

func RawURLAddParams(raw string, params map[string]string) (string, error)

RawURLAddParams adds multiple query parameters to raw url.

func RawURLDelParams

func RawURLDelParams(raw string, keys ...string) (string, error)

RawURLDelParams deletes multiple query paramters from raw url.

func RawURLGetAllParams

func RawURLGetAllParams(raw string) (map[string][]string, error)

RawURLGetAllParams gets all query parameter for all keys from raw url. E.g. if rawURL=http://www.aspxfans.com:8080/news/index.asp?boardID=520&page=1&page=2#name will get map[boardID:[520] page:[1 2]].

func RawURLGetDomain

func RawURLGetDomain(rawURL string) (string, error)

RawURLGetDomain gets the domain from raw url. E.g. if rawURL=http://www.aspxfans.com:8080/news/index.asp?boardID=520&page=1&page=2#name will get www.aspxfans.com.

func RawURLGetParam

func RawURLGetParam(raw, key string) (string, error)

RawURLGetParam gets the first query parameter for the specified key from raw url, even though key has multiple parameters. E.g. rawURL=http://www.aspxfans.com:8080/news/index.asp?boardID=520&page=1&page=2#name and key="page" will get "1".

func RawURLGetParams

func RawURLGetParams(raw, key string) ([]string, error)

RawURLGetParams gets all query parameter for the specified key from raw url if key has multiple parameters. E.g. if rawURL=http://www.aspxfans.com:8080/news/index.asp?boardID=520&page=1&page=2#name and key=page will get [1 2].

func RawURLGetPort

func RawURLGetPort(raw string) (string, error)

RawURLGetPort gets the port from raw url. E.g. if rawURL=http://www.aspxfans.com:8080/news/index.asp?boardID=520&page=1&page=2#name will get 8080.

func RawURLSetParam

func RawURLSetParam(raw, key, value string) (string, error)

RawURLSetParam sets query paramter to raw url. If the query key does not exist, it will be added to the url. E.g. if rawURL=http://www.aspxfans.com:8080/news/index.asp?boardID=520&page=1&page=2#name and key=page value=3 will get http://www.aspxfans.com:8080/news/index.asp?boardID=520&page=3#name.

func RawURLSetParams

func RawURLSetParams(rawURL string, params map[string]string) (string, error)

RawURLSetParams sets multiple query paramter to raw url.

func Swap16

func Swap16(i uint16) uint16

Swap16 swap a 16 bit value if aren't big endian

func Swap32

func Swap32(i uint32) uint32

Swap32 swap a 32 bit value if aren't big endian

func U32ToIPv4

func U32ToIPv4(ip uint32) net.IP

U32ToIPv4 converts uint32 to ipv4(a.b.c.d) in host byte order.

func U32ToIPv4Str

func U32ToIPv4Str(ip uint32) string

U32ToIPv4Str converts uint32 to IPv4 string in host byte order.

Types

This section is empty.

Jump to

Keyboard shortcuts

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