netutil

package
v0.0.0-...-5616126 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2025 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/maintell/goutil/netutil

Go docs

Usage

import "github.com/maintell/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

func FreePort() (port int, err error)

FreePort returns a free port.

func GetLocalIPs

func GetLocalIPs() (ips []string)

GetLocalIPs get local IPs, will panic if error.

func HostIP

func HostIP() ([]string, error)

HostIP returns the IP addresses of the localhost.

func IPv4

func IPv4() (ip string)

IPv4 get internal IPv4 for host.

func IPv6

func IPv6() (ip string)

IPv6 get internal IPv6

func InternalIP

func InternalIP() (ip string)

InternalIP get internal IP for host.

func InternalIPv1

func InternalIPv1() (ip string)

InternalIPv1 get internal IP buy old logic

func InternalIPv4

func InternalIPv4() string

InternalIPv4 get internal IPv4 for host.

func InternalIPv6

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