gemini-code-assist[bot] commented on code in PR #38438:
URL: https://github.com/apache/beam/pull/38438#discussion_r3219221427


##########
sdks/go/test/integration/io/xlang/jdbc/jdbc_test.go:
##########
@@ -60,8 +59,8 @@ func setupTestContainer(ctx context.Context, t *testing.T, 
dbname, username, pas
        }
        hostname := "localhost"
 
-       dbURL := func(host string, port nat.Port) string {
-               return fmt.Sprintf("postgres://%s:%s@%s:%s/%s?sslmode=disable", 
username, password, host, port.Port(), dbname)
+       dbURL := func(host string, port string) string {
+               return fmt.Sprintf("postgres://%s:%s@%s:%s/%s?sslmode=disable", 
username, password, host, port, dbname)

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   Using `fmt.Sprintf` with `%s:%s` for host and port can result in an invalid 
URL if the host is an IPv6 address (e.g., `::1:5432` instead of `[::1]:5432`). 
Using `net.JoinHostPort` ensures the host and port are correctly formatted for 
all address types. Note: This requires importing the `net` package.
   
   ```suggestion
                return fmt.Sprintf("postgres://%s:%s@%s/%s?sslmode=disable", 
username, password, net.JoinHostPort(host, port), dbname)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to