port

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2023 License: MIT Imports: 6 Imported by: 0

README

go-dynamic-port-allocator

Go CI CodeQL

A Go library for allocate ports, dynamically.

Example

import (
	...
	port "github.com/1eedaegon/go-dynamic-port-allocator"
	...
)

ports := port.Get(3)
// ports is something like []int{10000, 10001, 10002}

Or

import (
	...
	port "github.com/1eedaegon/go-dynamic-port-allocator"
	...
)

ports := port.GetS(3)
// ports is something like []string{"10000", "10001", "10002"}

License

MIT

Documentation

Overview

Package port exposes an unused port when execute: Get(n int)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(n int) []int

Get returns n ports that are free to use, panicing if it can't succeed.

func GetS

func GetS(n int) []string

GetS returns n ports as strings that are free to use, panicing if it can't succeed.

func GetSWithErr

func GetSWithErr(n int) ([]string, error)

GetS return n ports (as strings) that are free to use.

func GetWithErr

func GetWithErr(n int) (ports []int, err error)

Get returns n ports that are free to use.

Types

This section is empty.

Jump to

Keyboard shortcuts

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