DEV Community

loading...

go-portfinder: Go implementation of npm portfinder

pgollangi profile image Prasanna Kumar ・1 min read

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

Installation

$ go get github.com/pgollangi/go-portfinder
Enter fullscreen mode Exit fullscreen mode

Usage

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
     })
}
Enter fullscreen mode Exit fullscreen mode

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

Discussion (0)

pic
Editor guide