diff options
author | Michael Muré <batolettre@gmail.com> | 2020-02-05 22:03:19 +0100 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2020-02-05 22:33:03 +0100 |
commit | 1d4bb7ceb0cef79d68df0bacc913b01e40e6ddd6 (patch) | |
tree | e088b0fa43058afde1db71541d8fcb4b94905d6e /vendor/github.com/phayes/freeport/freeport.go | |
parent | f093be96e98284580d61664adecd0a2ff8b354e4 (diff) | |
download | git-bug-1d4bb7ceb0cef79d68df0bacc913b01e40e6ddd6.tar.gz |
migrate to go modules
Diffstat (limited to 'vendor/github.com/phayes/freeport/freeport.go')
-rw-r--r-- | vendor/github.com/phayes/freeport/freeport.go | 30 |
1 files changed, 0 insertions, 30 deletions
diff --git a/vendor/github.com/phayes/freeport/freeport.go b/vendor/github.com/phayes/freeport/freeport.go deleted file mode 100644 index c44b60df..00000000 --- a/vendor/github.com/phayes/freeport/freeport.go +++ /dev/null @@ -1,30 +0,0 @@ -package freeport - -import ( - "net" -) - -// GetFreePort asks the kernel for a free open port that is ready to use. -func GetFreePort() (int, error) { - addr, err := net.ResolveTCPAddr("tcp", "localhost:0") - if err != nil { - return 0, err - } - - l, err := net.ListenTCP("tcp", addr) - if err != nil { - return 0, err - } - defer l.Close() - return l.Addr().(*net.TCPAddr).Port, nil -} - -// GetPort is deprecated, use GetFreePort instead -// Ask the kernel for a free open port that is ready to use -func GetPort() int { - port, err := GetFreePort() - if err != nil { - panic(err) - } - return port -} |