Skip to content

Commit 123da8e

Browse files
authored
Add go1.16 support (#1740)
1 parent 4dc0dc3 commit 123da8e

File tree

8 files changed

+15
-103
lines changed

8 files changed

+15
-103
lines changed

.github/workflows/pr.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- name: Install Go
1616
uses: actions/setup-go@v2
1717
with:
18-
go-version: 1.15
18+
go-version: 1.16
1919
- name: Checkout code
2020
uses: actions/checkout@v2
2121
- name: Check go mod
@@ -41,7 +41,7 @@ jobs:
4141
- name: Install Go
4242
uses: actions/setup-go@v2
4343
with:
44-
go-version: 1.15 # test only the latest go version to speed up CI
44+
go-version: 1.16 # test only the latest go version to speed up CI
4545
- name: Run tests
4646
run: make.exe test
4747
continue-on-error: true
@@ -53,7 +53,7 @@ jobs:
5353
- name: Install Go
5454
uses: actions/setup-go@v2
5555
with:
56-
go-version: 1.15 # test only the latest go version to speed up CI
56+
go-version: 1.16 # test only the latest go version to speed up CI
5757
- name: Run tests
5858
run: make test
5959
tests-on-unix:
@@ -62,9 +62,9 @@ jobs:
6262
strategy:
6363
matrix:
6464
golang:
65-
- 1.13
6665
- 1.14
6766
- 1.15
67+
- 1.16
6868
steps:
6969
- uses: actions/checkout@v2
7070
- name: Install Go
@@ -92,6 +92,6 @@ jobs:
9292
- name: Install Go
9393
uses: actions/setup-go@v2
9494
with:
95-
go-version: 1.15
95+
go-version: 1.16
9696
- name: Check generated files are up to date
9797
run: make fast_check_generated

.github/workflows/tag.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- name: Install Go
1515
uses: actions/setup-go@v2
1616
with:
17-
go-version: 1.15
17+
go-version: 1.16
1818
- name: Unshallow
1919
run: git fetch --prune --unshallow
2020

@@ -40,7 +40,7 @@ jobs:
4040
- name: Install Go
4141
uses: actions/setup-go@v2
4242
with:
43-
go-version: 1.15
43+
go-version: 1.16
4444

4545
- name: Unshallow
4646
run: git fetch --prune --unshallow

Makefile

+3-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ fast_generate: assets/github-action-config.json
4444

4545
fast_check_generated:
4646
$(MAKE) --always-make fast_generate
47-
git checkout -- go.mod go.sum # can differ between go1.12 and go1.13
47+
git checkout -- go.mod go.sum # can differ between go1.15 and go1.16
4848
git diff --exit-code # check no changes
4949

5050
release: .goreleaser.yml tools/goreleaser
@@ -78,7 +78,8 @@ assets/demo.svg: tools/svg-term tools/Dracula.itermcolors
7878
./tools/svg-term --cast=183662 --out assets/demo.svg --window --width 110 --height 30 --from 2000 --to 20000 --profile ./tools/Dracula.itermcolors --term iterm2
7979

8080
assets/github-action-config.json: FORCE golangci-lint
81-
go run ./scripts/gen_github_action_config/main.go $@
81+
# go run ./scripts/gen_github_action_config/main.go $@
82+
cd ./scripts/gen_github_action_config/; go run ./main.go ../../$@
8283

8384
go.mod: FORCE
8485
go mod tidy

build/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# stage 1 building the code
2-
FROM golang:1.15 as builder
2+
FROM golang:1.16 as builder
33

44
ARG VERSION
55
ARG SHORT_COMMIT
@@ -10,7 +10,7 @@ WORKDIR /golangci
1010
RUN CGO_ENABLED=0 go build -trimpath -ldflags "-s -w -X main.version=$VERSION -X main.commit=$SHORT_COMMIT -X main.date=$DATE" -o golangci-lint ./cmd/golangci-lint/main.go
1111

1212
# stage 2
13-
FROM golang:1.15
13+
FROM golang:1.16
1414
# don't place it into $GOPATH/bin because Drone mounts $GOPATH as volume
1515
COPY --from=builder /golangci/golangci-lint /usr/bin/
1616
CMD ["golangci-lint"]

build/Dockerfile.alpine

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# stage 1 building the code
2-
FROM golang:1.15-alpine as builder
2+
FROM golang:1.16-alpine as builder
33

44
ARG VERSION
55
ARG SHORT_COMMIT
@@ -15,7 +15,7 @@ RUN apk --no-cache add gcc musl-dev git mercurial
1515
RUN CGO_ENABLED=0 go build -trimpath -ldflags "-s -w -X main.version=$VERSION -X main.commit=$SHORT_COMMIT -X main.date=$DATE" -o golangci-lint ./cmd/golangci-lint/main.go
1616

1717
# stage 2
18-
FROM golang:1.15-alpine
18+
FROM golang:1.16-alpine
1919
# gcc is required to support cgo;
2020
# git and mercurial are needed most times for go get`, etc.
2121
# See https://github.com/docker-library/golang/issues/80

go.sum

-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/testdata/govet.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
)
1010

1111
func Govet() error {
12-
return &os.PathError{"first", "path", os.ErrNotExist} // ERROR "composites: `os.PathError` composite literal uses unkeyed fields"
12+
return &os.PathError{"first", "path", os.ErrNotExist} // ERROR "composites: \\`(os|io/fs)\\.PathError\\` composite literal uses unkeyed fields"
1313
}
1414

1515
func GovetShadow(f io.Reader, buf []byte) (err error) {

test/testdata/sqlclosecheck.go

-85
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,11 @@ import (
66
"database/sql"
77
"log"
88
"strings"
9-
10-
_ "github.com/go-sql-driver/mysql"
11-
"github.com/jmoiron/sqlx"
129
)
1310

1411
var (
1512
ctx context.Context
1613
db *sql.DB
17-
dbx *sqlx.DB
1814
age = 27
1915
userID = 43
2016
)
@@ -259,84 +255,3 @@ func stmtReturn() (*sql.Stmt, error) {
259255
func stmtReturnShort() (*sql.Stmt, error) {
260256
return db.PrepareContext(ctx, "SELECT username FROM users WHERE id = ?")
261257
}
262-
263-
func sqlxCorrectDefer() {
264-
rows, err := dbx.Queryx("SELECT name FROM users WHERE age=?", age)
265-
if err != nil {
266-
log.Fatal(err)
267-
}
268-
269-
defer rows.Close()
270-
271-
names := make([]string, 0)
272-
for rows.Next() {
273-
var name string
274-
if err := rows.Scan(&name); err != nil {
275-
log.Fatal(err)
276-
}
277-
names = append(names, name)
278-
}
279-
280-
// Check for errors from iterating over rows.
281-
if err := rows.Err(); err != nil {
282-
log.Fatal(err)
283-
}
284-
log.Printf("%s are %d years old", strings.Join(names, ", "), age)
285-
}
286-
287-
func sqlxNonDeferClose() {
288-
rows, err := dbx.Queryx("SELECT name FROM users WHERE age=?", age)
289-
if err != nil {
290-
log.Fatal(err)
291-
}
292-
293-
names := make([]string, 0)
294-
for rows.Next() {
295-
var name string
296-
if err := rows.Scan(&name); err != nil {
297-
log.Fatal(err)
298-
}
299-
names = append(names, name)
300-
}
301-
302-
// Check for errors from iterating over rows.
303-
if err := rows.Err(); err != nil {
304-
log.Fatal(err)
305-
}
306-
log.Printf("%s are %d years old", strings.Join(names, ", "), age)
307-
308-
rows.Close() // ERROR "Close should use defer"
309-
}
310-
311-
func sqlxMissingClose() {
312-
rows, err := dbx.Queryx("SELECT name FROM users WHERE age=?", age) // ERROR "Rows/Stmt was not closed"
313-
if err != nil {
314-
log.Fatal(err)
315-
}
316-
317-
// defer rows.Close()
318-
319-
names := make([]string, 0)
320-
for rows.Next() {
321-
var name string
322-
if err := rows.Scan(&name); err != nil {
323-
log.Fatal(err)
324-
}
325-
names = append(names, name)
326-
}
327-
328-
// Check for errors from iterating over rows.
329-
if err := rows.Err(); err != nil {
330-
log.Fatal(err)
331-
}
332-
log.Printf("%s are %d years old", strings.Join(names, ", "), age)
333-
}
334-
335-
func sqlxReturnRows() (*sqlx.Rows, error) {
336-
rows, err := dbx.Queryx("SELECT name FROM users WHERE age=?", age)
337-
if err != nil {
338-
return nil, err
339-
}
340-
341-
return rows, nil
342-
}

0 commit comments

Comments
 (0)