From 677ffedd915ee3a5ec05b4b50160f0ee744b5452 Mon Sep 17 00:00:00 2001 From: Clement Date: Thu, 12 Sep 2024 11:05:40 +0800 Subject: [PATCH] fix: should open browser with the correct port --- internal/rpc.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/rpc.go b/internal/rpc.go index 19e8429..d02c5c7 100644 --- a/internal/rpc.go +++ b/internal/rpc.go @@ -1,7 +1,6 @@ package internal import ( - "errors" "fmt" "log" "net" @@ -25,6 +24,7 @@ func StartServeGrpc(gs *grpc.Server, conf *config.LivePprofConfig) { if err != nil { logging.Sugar.Fatal(err) } + conf.Port = port logging.Sugar.Infof("listening on %s", l.Addr().String()) addr := fmt.Sprintf("%s:%d", strings.Replace(conf.Host, "0.0.0.0", "localhost", 1), port) @@ -59,7 +59,7 @@ func StartServeGrpc(gs *grpc.Server, conf *config.LivePprofConfig) { func findPort(port uint, host string) (net.Listener, uint, error) { for { if port > 65535 || port == 0 { - return nil, 0, errors.New("port out of range [1, 65535]") + return nil, 0, fmt.Errorf("port %d is out of range [1, 65535]", port) } addr := fmt.Sprintf("%s:%d", host, port) l, err := net.Listen("tcp", addr)