netutil

package
v0.6.15 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: MIT Imports: 3 Imported by: 0

README

Net Utils

  • provide some network utils. eg: InternalIPv4
  • sub package:
    • httpctypes - provide some commonly http content types.
    • httpheader - provide some commonly http header names.
    • httpreq - provide some http request utils

Install

go get github.com/gookit/goutil/netutil

Go docs

Usage

import "github.com/gookit/goutil/netutil"
// Get internal IPv4 address
netutil.InternalIPv4()

Testings

go test -v ./netutil/...

Test limit by regexp:

go test -v -run ^TestSetByKeys ./netutil/...

Documentation

Overview

Package netutil provide some network util functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FreePort added in v0.6.13

func FreePort() (port int, err error)

FreePort returns a free port.

func GetLocalIPs added in v0.6.10

func GetLocalIPs() (ips []string)

GetLocalIPs get local IPs, will panic if error.

func HostIP added in v0.6.13

func HostIP() ([]string, error)

HostIP returns the IP addresses of the localhost.

func IPv4 added in v0.6.13

func IPv4() (ip string)

IPv4 get internal IPv4 for host.

func IPv6 added in v0.6.13

func IPv6() (ip string)

IPv6 get internal IPv6

func InternalIP

func InternalIP() (ip string)

InternalIP get internal IP for host.

func InternalIPv1 added in v0.6.11

func InternalIPv1() (ip string)

InternalIPv1 get internal IP buy old logic

func InternalIPv4 added in v0.5.0

func InternalIPv4() string

InternalIPv4 get internal IPv4 for host.

func InternalIPv6 added in v0.5.0

func InternalIPv6() string

InternalIPv6 get internal IPv6

Types

This section is empty.

Directories

Path Synopsis
Package httpctype list some common http content-type
Package httpctype list some common http content-type
Package httpheader provides some common http header names.
Package httpheader provides some common http header names.
Package httpreq provide an simple http requester and some useful util functions.
Package httpreq provide an simple http requester and some useful util functions.

Jump to

Keyboard shortcuts

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