summaryrefslogtreecommitdiff
path: root/utils/ports.go
diff options
context:
space:
mode:
authorSascha Grunert <sgrunert@redhat.com>2022-07-05 12:13:31 +0200
committerSascha Grunert <sgrunert@redhat.com>2022-07-05 12:13:33 +0200
commit49cb288df3224da71556e27d2e73e06d446c61f2 (patch)
tree7a69d9bbc60eb067f0e39d275648e10d577d5f22 /utils/ports.go
parent773eead54e2e0877e92d5871625a6cc32c582d30 (diff)
downloadpodman-49cb288df3224da71556e27d2e73e06d446c61f2.tar.gz
podman-49cb288df3224da71556e27d2e73e06d446c61f2.tar.bz2
podman-49cb288df3224da71556e27d2e73e06d446c61f2.zip
hack/test/utils: switch to golang native error wrapping
We now use the golang error wrapping format specifier `%w` instead of the deprecated github.com/pkg/errors package. [NO NEW TESTS NEEDED] Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
Diffstat (limited to 'utils/ports.go')
-rw-r--r--utils/ports.go9
1 files changed, 4 insertions, 5 deletions
diff --git a/utils/ports.go b/utils/ports.go
index 57a6f8275..eea060433 100644
--- a/utils/ports.go
+++ b/utils/ports.go
@@ -1,26 +1,25 @@
package utils
import (
+ "fmt"
"net"
"strconv"
-
- "github.com/pkg/errors"
)
// Find a random, open port on the host.
func GetRandomPort() (int, error) {
l, err := net.Listen("tcp", ":0")
if err != nil {
- return 0, errors.Wrapf(err, "unable to get free TCP port")
+ return 0, fmt.Errorf("unable to get free TCP port: %w", err)
}
defer l.Close()
_, randomPort, err := net.SplitHostPort(l.Addr().String())
if err != nil {
- return 0, errors.Wrapf(err, "unable to determine free port")
+ return 0, fmt.Errorf("unable to determine free port: %w", err)
}
rp, err := strconv.Atoi(randomPort)
if err != nil {
- return 0, errors.Wrapf(err, "unable to convert random port to int")
+ return 0, fmt.Errorf("unable to convert random port to int: %w", err)
}
return rp, nil
}