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

Upgrade Go version to 1.21 #1218

Merged
merged 1 commit into from
Feb 22, 2024
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
Upgrade Go version to 1.21
Signed-off-by: Yun Long <[email protected]>
  • Loading branch information
xxx7xxxx committed Feb 21, 2024
commit b622c6946ad22bc28c3c8bba3f57e6d9aebed90d
30 changes: 14 additions & 16 deletions .github/workflows/code.analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,25 @@ on:
- ".github/workflows/code.analysis.yml"

env:
GO_VERSION: "1.20"
GO_VERSION: "1.21"

jobs:

analysis:
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}

- name: Check out code into the Go module directory
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}

- name: Check out code into the Go module directory
uses: actions/checkout@v3
- name: Revive Action
uses: morphy2k/[email protected]

- name: Revive Action
uses: morphy2k/[email protected]
- name: Check formatting
run: test -z $(gofmt -l .) || (gofmt -l . && exit 1)

- name: Check formatting
run: test -z $(gofmt -l .) || (gofmt -l . && exit 1)

- name: misspell
uses: sobolevn/[email protected]
- name: misspell
uses: sobolevn/[email protected]
26 changes: 12 additions & 14 deletions .github/workflows/golangci.lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,22 @@ on:
- ".github/workflows/golangci.lint.yml"

env:
GO_VERSION: "1.20"
GO_VERSION: "1.21"

jobs:

analysis:
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}

- name: Check out code into the Go module directory
uses: actions/checkout@v3
- name: Check out code into the Go module directory
uses: actions/checkout@v3

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.54
args: --timeout=30m --disable=errcheck --exclude="SA1019"
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.54
args: --timeout=30m --disable=errcheck --exclude="SA1019"
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- "v*"

env:
GO_VERSION: "1.20"
GO_VERSION: "1.21"

permissions:
contents: write
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ on:
- ".github/workflows/test.yml"

env:
GO_VERSION: "1.20"
GO_VERSION: "1.21"

jobs:
test:
Expand All @@ -45,7 +45,7 @@ jobs:
run: |
make test TEST_FLAGS="-race -coverprofile=coverage.txt -covermode=atomic"

- name: Upload coverage to Codecov
- name: Upload coverage to Codecov
uses: codecov/[email protected]
with:
file: ./coverage.txt
Expand Down
13 changes: 10 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ export GO111MODULE=on
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
MKFILE_DIR := $(dir $(MKFILE_PATH))
RELEASE_DIR := ${MKFILE_DIR}bin
GO_PATH := $(shell go env | grep GOPATH | awk -F '"' '{print $$2}')
GO_PATH := $(shell go env | grep GOPATH | awk -F "=" '{print $$2}' | tr -d "'")
INTEGRATION_TEST_PATH := build/test

# Image Name
IMAGE_NAME?=megaease/easegress
BUILDER_IMAGE_NAME?=megaease/golang:1.21.7-alpine

# Version
RELEASE?=v2.7.0
Expand Down Expand Up @@ -94,15 +95,21 @@ build_docker:
cd ${MKFILE_DIR}
mkdir -p build/cache
mkdir -p build/bin
docker run -w /egsrc -u ${shell id -u}:${shell id -g} --rm \
docker run -w /egsrc --rm \
-v ${GO_PATH}:/gopath -v ${MKFILE_DIR}:/egsrc -v ${MKFILE_DIR}build/cache:/gocache \
-e GOPROXY=https://goproxy.io,direct -e GOCACHE=/gocache -e GOPATH=/gopath \
megaease/golang:1.21.0-alpine make build DOCKER=true
${BUILDER_IMAGE_NAME} make build DOCKER=true
docker buildx build --platform linux/amd64 --load -t ${IMAGE_NAME}:${RELEASE} -f ./build/package/Dockerfile .
docker tag ${IMAGE_NAME}:${RELEASE} ${IMAGE_NAME}:latest
docker tag ${IMAGE_NAME}:latest ${IMAGE_NAME}:server-sidecar
docker tag ${IMAGE_NAME}:latest ${IMAGE_NAME}:easemesh

build_golang_docker:
docker buildx build \
--platform linux/amd64 \
-t ${BUILDER_IMAGE_NAME} \
-f build/package/Dockerfile.builder .

test:
cd ${MKFILE_DIR}
go mod tidy
Expand Down
6 changes: 3 additions & 3 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ Supported [Go versions](https://go.dev/dl/):

| Version | Supported |
| ------- | ------------------ |
| 1.20.x | :white_check_mark: |
| 1.19.x | :white_check_mark: |
| < 1.19 | :x: |
| 1.22.x | :white_check_mark: |
| 1.21.x | :white_check_mark: |
| < 1.21 | :x: |

# Reporting a Vulnerability

Expand Down
2 changes: 1 addition & 1 deletion build/package/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
# To build docker images from this file, please build with command:
# make build_docker
FROM alpine:3.18
FROM alpine:3.19

WORKDIR /opt/easegress

Expand Down
2 changes: 1 addition & 1 deletion build/package/Dockerfile.builder
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
FROM golang:1.21.0-alpine
FROM golang:1.21.7-alpine
RUN apk --no-cache add make git
localvar marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion build/package/Dockerfile.goreleaser
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine:3.18
FROM alpine:3.19

WORKDIR /opt/easegress

Expand Down
4 changes: 2 additions & 2 deletions cmd/client/general/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func HandleReqWithStreamResp(httpMethod string, path string, yamlBody []byte) (i
return nil, fmt.Errorf("read response body failed: %v", err)
}

// https://github.com/golang/go/blob/release-branch.go1.20/src/net/http/server.go#L1878-L1885
// https://github.com/golang/go/blob/release-branch.go1.21/src/net/http/server.go#L1892-L1899
if strings.Contains(string(body), "Client sent an HTTP request to an HTTPS server") {
resp, err = doRequest(httpMethod, HTTPSProtocol+strings.TrimPrefix(url, HTTPProtocol), jsonBody, client)
if err != nil {
Expand Down Expand Up @@ -207,7 +207,7 @@ func HandleRequest(httpMethod string, path string, yamlBody []byte) (body []byte
}

msg := string(body)
// https://github.com/golang/go/blob/release-branch.go1.20/src/net/http/server.go#L1878-L1885
// https://github.com/golang/go/blob/release-branch.go1.21/src/net/http/server.go#L1892-L1899
if strings.HasPrefix(url, HTTPProtocol) && resp.StatusCode == http.StatusBadRequest && strings.Contains(msg, "Client sent an HTTP request to an HTTPS server") {
resp, body, err = doRequestWithBody(httpMethod, HTTPSProtocol+strings.TrimPrefix(url, HTTPProtocol), jsonBody, client)
if err != nil {
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/megaease/easegress/v2

go 1.20
go 1.21

require (
github.com/ArthurHlt/go-eureka-client v1.1.0
Expand Down
Loading
Loading