From 840acea49be91f7420c7c964766894fba5a5809d Mon Sep 17 00:00:00 2001
From: Doug Fawley <dfawley@google.com>
Date: Fri, 11 Aug 2023 11:01:03 -0700
Subject: [PATCH 1/2] *: remove references to old versions of go

---
 Documentation/proxy.md                    |  5 +-
 README.md                                 | 58 +++++------------------
 internal/channelz/util_test.go            |  4 --
 internal/transport/handler_server_test.go | 28 ++---------
 interop/observability/Dockerfile          |  4 +-
 test/channelz_linux_test.go               |  4 --
 test/kokoro/xds.sh                        |  5 +-
 vet.sh                                    |  2 +-
 8 files changed, 25 insertions(+), 85 deletions(-)

diff --git a/Documentation/proxy.md b/Documentation/proxy.md
index 189cdfbcb09b..59f1ed27925c 100644
--- a/Documentation/proxy.md
+++ b/Documentation/proxy.md
@@ -1,9 +1,8 @@
 # Proxy
 
 HTTP CONNECT proxies are supported by default in gRPC. The proxy address can be
-specified by the environment variables `HTTPS_PROXY` and `NO_PROXY`.  Before Go
-1.16, if the `HTTPS_PROXY` environment variable is unset, `HTTP_PROXY` will be
-used instead.  (Note that these environment variables are case insensitive.)
+specified by the environment variables `HTTPS_PROXY` and `NO_PROXY`.  (Note that
+these environment variables are case insensitive.)
 
 ## Custom proxy
 
diff --git a/README.md b/README.md
index 0e6ae69a5846..1bc92248cb47 100644
--- a/README.md
+++ b/README.md
@@ -14,21 +14,14 @@ RPC framework that puts mobile and HTTP/2 first. For more information see the
 
 ## Installation
 
-With [Go module][] support (Go 1.11+), simply add the following import
+Simply add the following import to your code, and then `go [build|run|test]`
+will automatically fetch the necessary dependencies:
+
 
 ```go
 import "google.golang.org/grpc"
 ```
 
-to your code, and then `go [build|run|test]` will automatically fetch the
-necessary dependencies.
-
-Otherwise, to install the `grpc-go` package, run the following command:
-
-```console
-$ go get -u google.golang.org/grpc
-```
-
 > **Note:** If you are trying to access `grpc-go` from **China**, see the
 > [FAQ](#FAQ) below.
 
@@ -56,15 +49,6 @@ To build Go code, there are several options:
 
 - Set up a VPN and access google.golang.org through that.
 
-- Without Go module support: `git clone` the repo manually:
-
-  ```sh
-  git clone https://github.com/grpc/grpc-go.git $GOPATH/src/google.golang.org/grpc
-  ```
-
-  You will need to do the same for all of grpc's dependencies in `golang.org`,
-  e.g. `golang.org/x/net`.
-
 - With Go module support: it is possible to use the `replace` feature of `go
   mod` to create aliases for golang.org packages.  In your project's directory:
 
@@ -76,33 +60,13 @@ To build Go code, there are several options:
   ```
 
   Again, this will need to be done for all transitive dependencies hosted on
-  golang.org as well. For details, refer to [golang/go issue #28652](https://github.com/golang/go/issues/28652).
+  golang.org as well. For details, refer to [golang/go issue
+  #28652](https://github.com/golang/go/issues/28652).
 
 ### Compiling error, undefined: grpc.SupportPackageIsVersion
 
-#### If you are using Go modules:
-
-Ensure your gRPC-Go version is `require`d at the appropriate version in
-the same module containing the generated `.pb.go` files.  For example,
-`SupportPackageIsVersion6` needs `v1.27.0`, so in your `go.mod` file:
-
-```go
-module <your module name>
-
-require (
-    google.golang.org/grpc v1.27.0
-)
-```
-
-#### If you are *not* using Go modules:
-
-Update the `proto` package, gRPC package, and rebuild the `.proto` files:
-
-```sh
-go get -u github.com/golang/protobuf/{proto,protoc-gen-go}
-go get -u google.golang.org/grpc
-protoc --go_out=plugins=grpc:. *.proto
-```
+Please update to the latest version of gRPC-Go using
+`go get google.golang.org/grpc`.
 
 ### How to turn on logging
 
@@ -121,9 +85,11 @@ possible reasons, including:
  1. mis-configured transport credentials, connection failed on handshaking
  1. bytes disrupted, possibly by a proxy in between
  1. server shutdown
- 1. Keepalive parameters caused connection shutdown, for example if you have configured
-    your server to terminate connections regularly to [trigger DNS lookups](https://github.com/grpc/grpc-go/issues/3170#issuecomment-552517779).
-    If this is the case, you may want to increase your [MaxConnectionAgeGrace](https://pkg.go.dev/google.golang.org/grpc/keepalive?tab=doc#ServerParameters),
+ 1. Keepalive parameters caused connection shutdown, for example if you have
+    configured your server to terminate connections regularly to [trigger DNS
+    lookups](https://github.com/grpc/grpc-go/issues/3170#issuecomment-552517779).
+    If this is the case, you may want to increase your
+    [MaxConnectionAgeGrace](https://pkg.go.dev/google.golang.org/grpc/keepalive?tab=doc#ServerParameters),
     to allow longer RPC calls to finish.
 
 It can be tricky to debug this because the error happens on the client side but
diff --git a/internal/channelz/util_test.go b/internal/channelz/util_test.go
index 9de6679043d7..da0fd30b1905 100644
--- a/internal/channelz/util_test.go
+++ b/internal/channelz/util_test.go
@@ -19,10 +19,6 @@
  *
  */
 
-// The test in this file should be run in an environment that has go1.10 or later,
-// as the function SyscallConn() (required to get socket option) was introduced
-// to net.TCPListener in go1.10.
-
 package channelz_test
 
 import (
diff --git a/internal/transport/handler_server_test.go b/internal/transport/handler_server_test.go
index 99ca211b323c..36b0864177e7 100644
--- a/internal/transport/handler_server_test.go
+++ b/internal/transport/handler_server_test.go
@@ -318,7 +318,7 @@ func (s) TestHandlerTransport_HandleStreams(t *testing.T) {
 		func(ctx context.Context, method string) context.Context { return ctx },
 	)
 	wantHeader := http.Header{
-		"Date":          {},
+		"Date":          nil,
 		"Content-Type":  {"application/grpc"},
 		"Trailer":       {"Grpc-Status", "Grpc-Message", "Grpc-Status-Details-Bin"},
 		"Custom-Header": {"Custom header value", "Another custom header value"},
@@ -352,7 +352,7 @@ func handleStreamCloseBodyTest(t *testing.T, statusCode codes.Code, msg string)
 		func(ctx context.Context, method string) context.Context { return ctx },
 	)
 	wantHeader := http.Header{
-		"Date":         {},
+		"Date":         nil,
 		"Content-Type": {"application/grpc"},
 		"Trailer":      {"Grpc-Status", "Grpc-Message", "Grpc-Status-Details-Bin"},
 	}
@@ -402,7 +402,7 @@ func (s) TestHandlerTransport_HandleStreams_Timeout(t *testing.T) {
 		func(ctx context.Context, method string) context.Context { return ctx },
 	)
 	wantHeader := http.Header{
-		"Date":         {},
+		"Date":         nil,
 		"Content-Type": {"application/grpc"},
 		"Trailer":      {"Grpc-Status", "Grpc-Message", "Grpc-Status-Details-Bin"},
 	}
@@ -489,7 +489,7 @@ func (s) TestHandlerTransport_HandleStreams_ErrDetails(t *testing.T) {
 		func(ctx context.Context, method string) context.Context { return ctx },
 	)
 	wantHeader := http.Header{
-		"Date":         {},
+		"Date":         nil,
 		"Content-Type": {"application/grpc"},
 		"Trailer":      {"Grpc-Status", "Grpc-Message", "Grpc-Status-Details-Bin"},
 	}
@@ -515,7 +515,7 @@ func (s) TestHandlerTransport_Drain(t *testing.T) {
 func checkHeaderAndTrailer(t *testing.T, rw testHandlerResponseWriter, wantHeader, wantTrailer http.Header) {
 	// For trailer-only responses, the trailer values might be reported as part of the Header. They will however
 	// be present in Trailer in either case. Hence, normalize the header by removing all trailer values.
-	actualHeader := cloneHeader(rw.Result().Header)
+	actualHeader := rw.Result().Header.Clone()
 	for _, trailerKey := range actualHeader["Trailer"] {
 		actualHeader.Del(trailerKey)
 	}
@@ -527,21 +527,3 @@ func checkHeaderAndTrailer(t *testing.T, rw testHandlerResponseWriter, wantHeade
 		t.Errorf("Trailer mismatch.\n got: %#v\n want: %#v", actualTrailer, wantTrailer)
 	}
 }
-
-// cloneHeader performs a deep clone of an http.Header, since the (http.Header).Clone() method was only added in
-// Go 1.13.
-func cloneHeader(hdr http.Header) http.Header {
-	if hdr == nil {
-		return nil
-	}
-
-	hdrClone := make(http.Header, len(hdr))
-
-	for k, vv := range hdr {
-		vvClone := make([]string, len(vv))
-		copy(vvClone, vv)
-		hdrClone[k] = vvClone
-	}
-
-	return hdrClone
-}
diff --git a/interop/observability/Dockerfile b/interop/observability/Dockerfile
index 7fcfc6df7865..d969e72abd44 100644
--- a/interop/observability/Dockerfile
+++ b/interop/observability/Dockerfile
@@ -17,7 +17,7 @@
 # Stage 1: Build the interop test client and server
 #
 
-FROM golang:1.17.13-bullseye as build
+FROM golang:1.21-bullseye as build
 
 WORKDIR /grpc-go
 COPY . .
@@ -36,7 +36,7 @@ RUN go build -o server/ server/server.go && \
 #   with the given parameters.
 #
 
-FROM golang:1.17.13-bullseye
+FROM golang:1.21-bullseye
 
 ENV GRPC_GO_LOG_SEVERITY_LEVEL info
 ENV GRPC_GO_LOG_VERBOSITY_LEVEL 2
diff --git a/test/channelz_linux_test.go b/test/channelz_linux_test.go
index e532fbb12c56..7d1407323334 100644
--- a/test/channelz_linux_test.go
+++ b/test/channelz_linux_test.go
@@ -16,10 +16,6 @@
  *
  */
 
-// The test in this file should be run in an environment that has go1.10 or later,
-// as the function SyscallConn() (required to get socket option) was
-// introduced to net.TCPListener in go1.10.
-
 package test
 
 import (
diff --git a/test/kokoro/xds.sh b/test/kokoro/xds.sh
index ca676f9d58ed..75865c340e9e 100755
--- a/test/kokoro/xds.sh
+++ b/test/kokoro/xds.sh
@@ -9,8 +9,9 @@ export GOPATH="${HOME}/gopath"
 pushd grpc-go/interop/xds/client
 # Install a version of Go supported by gRPC for the new features, e.g.
 # errors.Is()
-curl --retry 3 -O -L https://go.dev/dl/go1.17.3.linux-amd64.tar.gz
-sudo tar -C /usr/local -xf go1.17.3.linux-amd64.tar.gz
+gofilename=go1.21.0.linux-amd64.tar.gz
+curl --retry 3 -O -L "https://go.dev/dl/${gofilename}"
+sudo tar -C /usr/local -xf "${gofilename}"
 sudo ln -s /usr/local/go/bin/go /usr/bin/go
 # Retry go build on errors (e.g. go get connection errors), for at most 3 times
 for i in 1 2 3; do go build && break || sleep 5; done
diff --git a/vet.sh b/vet.sh
index 0919ae6a5a52..920e8263fb49 100755
--- a/vet.sh
+++ b/vet.sh
@@ -106,7 +106,7 @@ for MOD_FILE in $(find . -name 'go.mod'); do
   goimports -l . 2>&1 | not grep -vE "\.pb\.go"
   golint ./... 2>&1 | not grep -vE "/grpc_testing_not_regenerate/.*\.pb\.go:"
 
-  go mod tidy -compat=1.17
+  go mod tidy -compat=1.19
   git status --porcelain 2>&1 | fail_on_output || \
     (git status; git --no-pager diff; exit 1)
   popd

From 0af3cad6ea5703485ec781cf0a15b4ae412010a4 Mon Sep 17 00:00:00 2001
From: Doug Fawley <dfawley@google.com>
Date: Fri, 11 Aug 2023 11:39:43 -0700
Subject: [PATCH 2/2] xds interop 1.19->1.21

---
 interop/xds/client/Dockerfile | 2 +-
 interop/xds/server/Dockerfile | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/interop/xds/client/Dockerfile b/interop/xds/client/Dockerfile
index 0d2c44a521af..5b6e3f61c5e1 100644
--- a/interop/xds/client/Dockerfile
+++ b/interop/xds/client/Dockerfile
@@ -16,7 +16,7 @@
 # following command from grpc-go directory:
 # docker build -t <TAG> -f interop/xds/client/Dockerfile .
 
-FROM golang:1.19-alpine as build
+FROM golang:1.21-alpine as build
 
 # Make a grpc-go directory and copy the repo into it.
 WORKDIR /go/src/grpc-go
diff --git a/interop/xds/server/Dockerfile b/interop/xds/server/Dockerfile
index db5b2940953d..f7d1cf0ff022 100644
--- a/interop/xds/server/Dockerfile
+++ b/interop/xds/server/Dockerfile
@@ -16,7 +16,7 @@
 # following command from grpc-go directory:
 # docker build -t <TAG> -f interop/xds/server/Dockerfile .
 
-FROM golang:1.19-alpine as build
+FROM golang:1.21-alpine as build
 
 # Make a grpc-go directory and copy the repo into it.
 WORKDIR /go/src/grpc-go