Skip to content

Commit

Permalink
Upgrade to golang 1.20 (#633)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
Smirl and ktr0731 authored Feb 25, 2023
1 parent 5ed4a07 commit 2799931
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 363 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
go: ['1.17']
go: ['1.20']
steps:
- name: Set up Go ${{ matrix.go }}
uses: actions/setup-go@v3
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# syntax=docker/dockerfile:1.2

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

WORKDIR /src

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ $ docker run --rm -v "$(pwd):/mount:ro" \

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

Go v1.16 or later is required.
Go v1.20 or later is required.

``` sh
go install github.com/ktr0731/evans@latest
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/ktr0731/evans

go 1.17
go 1.20

require (
github.com/Songmu/gocredits v0.3.0
Expand Down
352 changes: 0 additions & 352 deletions go.sum

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions grpc/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/connectivity"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/metadata"
)

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

creds := credentials.NewTLS(&tlsCfg)
opts = append(opts, grpc.WithTransportCredentials(creds))

if serverName != "" {
if err := creds.OverrideServerName(serverName); err != nil {
return nil, errors.Wrapf(err, "failed to override the server name by '%s'", serverName)
}
opts = append(opts, grpc.WithAuthority(serverName))
}
opts = append(opts, grpc.WithTransportCredentials(creds))
}
ctx, cancel := context.WithTimeout(context.Background(), 7*time.Second)
defer cancel()
Expand Down
4 changes: 2 additions & 2 deletions grpc/grpcreflection/reflection.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ func getCtx(headers map[string][]string) context.Context {
// NewClient returns an instance of gRPC reflection client for gRPC protocol.
func NewClient(conn grpc.ClientConnInterface, headers map[string][]string) Client {
return &client{
client: gr.NewClient(getCtx(headers), grpc_reflection_v1alpha.NewServerReflectionClient(conn)),
client: gr.NewClientV1Alpha(getCtx(headers), grpc_reflection_v1alpha.NewServerReflectionClient(conn)),
}
}

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

Expand Down

0 comments on commit 2799931

Please sign in to comment.