Posts go-portfinder - A simple tool to find an open port on the current machine.
Post
Cancel

go-portfinder - A simple tool to find an open port on the current machine.

Go implementation of npm portfinder. A simple tool to find an open port on the current machine.

Repo: https://github.com/pgollangi/go-portfinder

  • Star if you find this tool useful.
  • Open an Issue if you come accross any problem using tool.
  • Submit a PR if you would like an improvement

Installation

1
$ go get github.com/pgollangi/go-portfinder

Usage

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package main

import (
	"github.com/pgollangi/go-portfinder"
)

func main(){
     // scans and returns first open port on all network interfaces of current machine.
     openPort, err := portfinder.GetPort(PortFinderOptions {
         StartPort: 9090,
         StopPort: 9099
     })

    // Check if a port is open
    isOpen, err := portfinder.IsOpen(8080)
}


This post is licensed under CC BY 4.0 by the author.