// +build !windows

package reuseport

import (
	"syscall"

	"golang.org/x/sys/unix"
)

func Control(network, address string, c syscall.RawConn) error {
	var err error
	c.Control(func(fd uintptr) {
		err = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEADDR, 1)
		if err != nil {
			return
		}

		err = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEPORT, 1)
		if err != nil {
			return
		}
	})
	return err
}

// +build !windows

package reuseport

import (
	"syscall"

	"golang.org/x/sys/unix"
)

func Control(network, address string, c syscall.RawConn) error {
	var err error
	c.Control(func(fd uintptr) {
		err = syscall.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEADDR, 1)
		if err != nil {
			return
		}

		err = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, syscall.SO_REUSEPORT, 1)
		if err != nil {
			return
		}
	})
	return err
}

--- 
+++ 
@@ -11,12 +11,12 @@
 func Control(network, address string, c syscall.RawConn) error {
 	var err error
 	c.Control(func(fd uintptr) {
-		err = syscall.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEADDR, 1)
+		err = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEADDR, 1)
 		if err != nil {
 			return
 		}
 
-		err = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, syscall.SO_REUSEPORT, 1)
+		err = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEPORT, 1)
 		if err != nil {
 			return
 		}
Use more constants from unix package

A Linux configuration I have is a lot fussier.
