mirror of
https://github.com/lwch/natpass.git
synced 2024-04-21 12:41:54 +00:00
16 lines
266 B
Go
16 lines
266 B
Go
package global
|
|
|
|
import (
|
|
"net"
|
|
|
|
"github.com/lwch/runtime"
|
|
)
|
|
|
|
// GeneratePort generate port for listen
|
|
func GeneratePort() uint16 {
|
|
l, err := net.ListenTCP("tcp", &net.TCPAddr{})
|
|
runtime.Assert(err)
|
|
defer l.Close()
|
|
return uint16(l.Addr().(*net.TCPAddr).Port)
|
|
}
|