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

Add go1.16 support #1740

Merged
merged 6 commits into from
Feb 17, 2021
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
10 changes: 5 additions & 5 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.15
go-version: 1.16
- name: Checkout code
uses: actions/checkout@v2
- name: Check go mod
Expand All @@ -41,7 +41,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.15 # test only the latest go version to speed up CI
go-version: 1.16 # test only the latest go version to speed up CI
- name: Run tests
run: make.exe test
continue-on-error: true
Expand All @@ -53,7 +53,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.15 # test only the latest go version to speed up CI
go-version: 1.16 # test only the latest go version to speed up CI
- name: Run tests
run: make test
tests-on-unix:
Expand All @@ -62,9 +62,9 @@ jobs:
strategy:
matrix:
golang:
- 1.13
- 1.14
- 1.15
- 1.16
steps:
- uses: actions/checkout@v2
- name: Install Go
Expand Down Expand Up @@ -92,6 +92,6 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.15
go-version: 1.16
- name: Check generated files are up to date
run: make fast_check_generated
4 changes: 2 additions & 2 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.15
go-version: 1.16
- name: Unshallow
run: git fetch --prune --unshallow

Expand All @@ -40,7 +40,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.15
go-version: 1.16

- name: Unshallow
run: git fetch --prune --unshallow
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fast_generate: assets/github-action-config.json

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

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

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

go.mod: FORCE
go mod tidy
Expand Down
4 changes: 2 additions & 2 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# stage 1 building the code
FROM golang:1.15 as builder
FROM golang:1.16 as builder

ARG VERSION
ARG SHORT_COMMIT
Expand All @@ -10,7 +10,7 @@ WORKDIR /golangci
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

# stage 2
FROM golang:1.15
FROM golang:1.16
# don't place it into $GOPATH/bin because Drone mounts $GOPATH as volume
COPY --from=builder /golangci/golangci-lint /usr/bin/
CMD ["golangci-lint"]
4 changes: 2 additions & 2 deletions build/Dockerfile.alpine
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# stage 1 building the code
FROM golang:1.15-alpine as builder
FROM golang:1.16-alpine as builder

ARG VERSION
ARG SHORT_COMMIT
Expand All @@ -15,7 +15,7 @@ RUN apk --no-cache add gcc musl-dev git mercurial
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

# stage 2
FROM golang:1.15-alpine
FROM golang:1.16-alpine
# gcc is required to support cgo;
# git and mercurial are needed most times for go get`, etc.
# See https://github.com/docker-library/golang/issues/80
Expand Down
4 changes: 0 additions & 4 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/testdata/govet.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

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

func GovetShadow(f io.Reader, buf []byte) (err error) {
Expand Down
85 changes: 0 additions & 85 deletions test/testdata/sqlclosecheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@ import (
"database/sql"
"log"
"strings"

_ "github.com/go-sql-driver/mysql"
"github.com/jmoiron/sqlx"
)

var (
ctx context.Context
db *sql.DB
dbx *sqlx.DB
age = 27
userID = 43
)
Expand Down Expand Up @@ -259,84 +255,3 @@ func stmtReturn() (*sql.Stmt, error) {
func stmtReturnShort() (*sql.Stmt, error) {
return db.PrepareContext(ctx, "SELECT username FROM users WHERE id = ?")
}

func sqlxCorrectDefer() {
rows, err := dbx.Queryx("SELECT name FROM users WHERE age=?", age)
if err != nil {
log.Fatal(err)
}

defer rows.Close()

names := make([]string, 0)
for rows.Next() {
var name string
if err := rows.Scan(&name); err != nil {
log.Fatal(err)
}
names = append(names, name)
}

// Check for errors from iterating over rows.
if err := rows.Err(); err != nil {
log.Fatal(err)
}
log.Printf("%s are %d years old", strings.Join(names, ", "), age)
}

func sqlxNonDeferClose() {
rows, err := dbx.Queryx("SELECT name FROM users WHERE age=?", age)
if err != nil {
log.Fatal(err)
}

names := make([]string, 0)
for rows.Next() {
var name string
if err := rows.Scan(&name); err != nil {
log.Fatal(err)
}
names = append(names, name)
}

// Check for errors from iterating over rows.
if err := rows.Err(); err != nil {
log.Fatal(err)
}
log.Printf("%s are %d years old", strings.Join(names, ", "), age)

rows.Close() // ERROR "Close should use defer"
}

func sqlxMissingClose() {
rows, err := dbx.Queryx("SELECT name FROM users WHERE age=?", age) // ERROR "Rows/Stmt was not closed"
if err != nil {
log.Fatal(err)
}

// defer rows.Close()

names := make([]string, 0)
for rows.Next() {
var name string
if err := rows.Scan(&name); err != nil {
log.Fatal(err)
}
names = append(names, name)
}

// Check for errors from iterating over rows.
if err := rows.Err(); err != nil {
log.Fatal(err)
}
log.Printf("%s are %d years old", strings.Join(names, ", "), age)
}

func sqlxReturnRows() (*sqlx.Rows, error) {
rows, err := dbx.Queryx("SELECT name FROM users WHERE age=?", age)
if err != nil {
return nil, err
}

return rows, nil
}