Skip to content

Commit 2799931

Browse files
Smirlktr0731
andauthored
Upgrade to golang 1.20 (#633)
* Upgrade to golang 1.20 * Fix golangci-lint issues. Pins the grpc reflection client to v1alpha1. Probably a future issue to upgrade that * go mod tidy --------- Co-authored-by: ktr0731 <[email protected]>
1 parent 5ed4a07 commit 2799931

File tree

7 files changed

+11
-363
lines changed

7 files changed

+11
-363
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
strategy:
88
matrix:
99
os: [ubuntu-latest, windows-latest, macOS-latest]
10-
go: ['1.17']
10+
go: ['1.20']
1111
steps:
1212
- name: Set up Go ${{ matrix.go }}
1313
uses: actions/setup-go@v3

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# syntax=docker/dockerfile:1.2
22

33
# Image page: <https://hub.docker.com/_/golang>
4-
FROM golang:1.18-alpine as builder
4+
FROM golang:1.20-alpine as builder
55

66
WORKDIR /src
77

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ $ docker run --rm -v "$(pwd):/mount:ro" \
9797

9898
### **[Not-recommended]** go install
9999

100-
Go v1.16 or later is required.
100+
Go v1.20 or later is required.
101101

102102
``` sh
103103
go install github.com/ktr0731/evans@latest

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/ktr0731/evans
22

3-
go 1.17
3+
go 1.20
44

55
require (
66
github.com/Songmu/gocredits v0.3.0

go.sum

Lines changed: 0 additions & 352 deletions
Large diffs are not rendered by default.

grpc/grpc.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"google.golang.org/grpc"
2020
"google.golang.org/grpc/connectivity"
2121
"google.golang.org/grpc/credentials"
22+
"google.golang.org/grpc/credentials/insecure"
2223
"google.golang.org/grpc/metadata"
2324
)
2425

@@ -117,7 +118,7 @@ type client struct {
117118
func NewClient(addr, serverName string, useReflection, useTLS bool, cacert, cert, certKey string, headers map[string][]string) (Client, error) {
118119
var opts []grpc.DialOption
119120
if !useTLS {
120-
opts = append(opts, grpc.WithInsecure())
121+
opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()))
121122
} else { // Enable TLS authentication
122123
var tlsCfg tls.Config
123124
if cacert != "" {
@@ -143,12 +144,11 @@ func NewClient(addr, serverName string, useReflection, useTLS bool, cacert, cert
143144
}
144145

145146
creds := credentials.NewTLS(&tlsCfg)
147+
opts = append(opts, grpc.WithTransportCredentials(creds))
148+
146149
if serverName != "" {
147-
if err := creds.OverrideServerName(serverName); err != nil {
148-
return nil, errors.Wrapf(err, "failed to override the server name by '%s'", serverName)
149-
}
150+
opts = append(opts, grpc.WithAuthority(serverName))
150151
}
151-
opts = append(opts, grpc.WithTransportCredentials(creds))
152152
}
153153
ctx, cancel := context.WithTimeout(context.Background(), 7*time.Second)
154154
defer cancel()

grpc/grpcreflection/reflection.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ func getCtx(headers map[string][]string) context.Context {
4747
// NewClient returns an instance of gRPC reflection client for gRPC protocol.
4848
func NewClient(conn grpc.ClientConnInterface, headers map[string][]string) Client {
4949
return &client{
50-
client: gr.NewClient(getCtx(headers), grpc_reflection_v1alpha.NewServerReflectionClient(conn)),
50+
client: gr.NewClientV1Alpha(getCtx(headers), grpc_reflection_v1alpha.NewServerReflectionClient(conn)),
5151
}
5252
}
5353

5454
// NewWebClient returns an instance of gRPC reflection client for gRPC-Web protocol.
5555
func NewWebClient(conn *grpcweb.ClientConn, headers map[string][]string) Client {
5656
return &client{
57-
client: gr.NewClient(getCtx(headers), grpcweb_reflection_v1alpha.NewServerReflectionClient(conn)),
57+
client: gr.NewClientV1Alpha(getCtx(headers), grpcweb_reflection_v1alpha.NewServerReflectionClient(conn)),
5858
}
5959
}
6060

0 commit comments

Comments
 (0)