Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: remove references to old versions of go #6545

Merged
merged 2 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions Documentation/proxy.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
58 changes: 12 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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:

Expand All @@ -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

Expand All @@ -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
Expand Down
4 changes: 0 additions & 4 deletions internal/channelz/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
28 changes: 5 additions & 23 deletions internal/transport/handler_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down Expand Up @@ -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"},
}
Expand Down Expand Up @@ -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"},
}
Expand Down Expand Up @@ -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"},
}
Expand All @@ -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)
}
Expand All @@ -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
}
4 changes: 2 additions & 2 deletions interop/observability/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 . .
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion interop/xds/client/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion interop/xds/server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions test/channelz_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
5 changes: 3 additions & 2 deletions test/kokoro/xds.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion vet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down