Categorygithub.com/seymourtang/go-reuse
modulepackage
1.0.0
Repository: https://github.com/seymourtang/go-reuse.git
Documentation: pkg.go.dev

# README

go-reuse

Go Report Card GitHub go.mod Go version Go Reference GitHub

Package go-reuse provides Listen functions that set socket options in order to be able to reuse ports on Windows,Linux and macOS platform.

Installation

go get github.com/seymourtang/go-reuse

Getting Started

package main

import (
	"fmt"
	"log"
	"net/http"
	"os"

	"github.com/seymourtang/go-reuse"
)

func main() {
	listener, err := reuse.Listen("tcp", ":8082")
	if err != nil {
		log.Fatalln(err)
	}
	defer func() {
		_ = listener.Close()
	}()

	s := &http.Server{}
	http.HandleFunc("/test", func(writer http.ResponseWriter, request *http.Request) {
		_, _ = fmt.Fprintf(writer, "gid:%d,pid:%d", os.Getegid(), os.Getpid())
	})

	log.Fatalln(s.Serve(listener))
}

# Packages

No description provided by the author

# Functions

No description provided by the author
No description provided by the author