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

chore: Bump to GoLang v1.22 #2911

Closed
Closed
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
2 changes: 1 addition & 1 deletion .github/workflows/check-tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# licenses/APL.txt.

# This workflow checks that go mod tidy command we have set for the specific
# go version is not broken, for example `go mod tidy -go=1.21.3`. This
# go version is not broken, for example `go mod tidy -go=1.2x.3`. This
# can cause some head scratching at times, so better catch this in the PR.
#
# Inaddition to that also checks that we are currently in a `tidy` state.
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/check-vulnerabilities.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Run govulncheck
uses: golang/govulncheck-action@v1
with:
go-version-input: "1.21"
go-package: ./...
go-version-file: 'go.mod'
check-latest: true
cache: false
go-package: ./...
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ verify:

.PHONY: tidy
tidy:
go mod tidy -go=1.21.3
go mod tidy -go=1.22

.PHONY: clean
clean:
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/sourcenetwork/defradb

go 1.21.3
go 1.22

require (
github.com/bits-and-blooms/bitset v1.13.0
Expand Down
6 changes: 1 addition & 5 deletions internal/lens/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,7 @@ func getCollectionHistory(
history := map[schemaVersionID]*collectionHistoryLink{}
schemaVersionsByColID := map[uint32]schemaVersionID{}

for _, c := range cols {
// Todo - this `col := c` can be removed with Go 1.22:
// https://github.com/sourcenetwork/defradb/issues/2431
col := c

for _, col := range cols {
// Convert the temporary types to the cleaner return type:
history[col.SchemaVersionID] = &collectionHistoryLink{
collection: &col,
Expand Down
5 changes: 2 additions & 3 deletions internal/planner/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,8 @@ func (n *dagScanNode) Next() (bool, error) {
// so that the last new cid will be at the front of the slice
n.queuedCids = append(make([]*cid.Cid, len(heads)), n.queuedCids...)

for i, h := range heads {
link := h // TODO remove when Go 1.22 #2431
n.queuedCids[len(heads)-i-1] = &link.Cid
for i, head := range heads {
n.queuedCids[len(heads)-i-1] = &head.Cid
}
}

Expand Down
14 changes: 3 additions & 11 deletions internal/request/graphql/schema/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,11 +420,7 @@ func (g *Generator) buildTypes(
// get all the defined types from the AST
objs := make([]*gql.Object, 0)

for _, c := range collections {
// Copy the loop variable before usage within the loop or it
// will be reassigned before the thunk is run
// TODO remove when Go 1.22
collection := c
for _, collection := range collections {
fieldDescriptions := collection.GetFields()
isEmbeddedObject := !collection.Description.Name.HasValue()
isQuerySource := len(collection.Description.QuerySources()) > 0
Expand Down Expand Up @@ -536,18 +532,14 @@ func (g *Generator) buildTypes(
// buildMutationInputTypes creates the input object types
// for collection create and update mutation operations.
func (g *Generator) buildMutationInputTypes(collections []client.CollectionDefinition) error {
for _, c := range collections {
if !c.Description.Name.HasValue() {
for _, collection := range collections {
if !collection.Description.Name.HasValue() {
// If the definition's collection is empty, this must be a collectionless
// schema, in which case users cannot mutate documents through it and we
// have no need to build mutation input types for it.
continue
}

// Copy the loop variable before usage within the loop or it
// will be reassigned before the thunk is run
// TODO remove when Go 1.22
collection := c
mutationInputName := collection.Description.Name.Value() + mutationInputNameSuffix

// check if mutation input type exists
Expand Down
4 changes: 2 additions & 2 deletions tools/cloud/aws/packer/build_aws_ami.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ build {
inline = [
"/usr/bin/cloud-init status --wait",
"sudo apt-get update && sudo apt-get install make build-essential -y",
"curl -OL https://golang.org/dl/go1.21.6.linux-amd64.tar.gz",
"rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.21.6.linux-amd64.tar.gz",
"curl -OL https://golang.org/dl/go1.22.6.linux-amd64.tar.gz",
"rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.22.6.linux-amd64.tar.gz",
"export PATH=$PATH:/usr/local/go/bin",
"git clone \"https://git@$DEFRADB_GIT_REPO\"",
"cd ./defradb || { printf \"\\\ncd into defradb failed.\\\n\" && exit 2; }",
Expand Down
12 changes: 4 additions & 8 deletions tools/configs/golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ run:

# Define the Go version limit.
# Default: use Go version from the go.mod file, fallback on the env var `GOVERSION`.
go: "1.21"
go: "1.22"

#=====================================================================================[ Output Configuration Options ]
output:
Expand Down Expand Up @@ -105,15 +105,11 @@ linters:

enable-all: false

disable:
# - prealloc

disable-all: true

enable:
- errcheck
- errorlint
- exportloopref
- forbidigo
- goconst
- gofmt
Expand Down Expand Up @@ -263,7 +259,7 @@ linters-settings:

gosimple:
# Select the Go version to target.
go: "1.21"
go: "1.22"
# https://staticcheck.io/docs/options#checks
checks: ["all", "-S1038"]
# Turn on all except (these are disabled):
Expand Down Expand Up @@ -356,13 +352,13 @@ linters-settings:

staticcheck:
# Select the Go version to target.
go: "1.21"
go: "1.22"
# https://staticcheck.io/docs/options#checks
checks: ["all"]

unused:
# Select the Go version to target.
go: "1.21"
go: "1.22"

whitespace:
# Enforces newlines (or comments) after every multi-line if statement.
Expand Down
2 changes: 1 addition & 1 deletion tools/defradb.containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# An image to run defradb.

# Stage: PLAYGROUND_BUILD
FROM docker.io/node:20 AS PLAYGROUND_BUILD

Check warning on line 6 in tools/defradb.containerfile

View workflow job for this annotation

GitHub Actions / Validate containerfile job

Stage names should be lowercase

StageNameCasing: Stage name 'PLAYGROUND_BUILD' should be lowercase More info: https://docs.docker.com/go/dockerfile/rule/stage-name-casing/

Check warning on line 6 in tools/defradb.containerfile

View workflow job for this annotation

GitHub Actions / Validate containerfile job

Stage names should be lowercase

StageNameCasing: Stage name 'PLAYGROUND_BUILD' should be lowercase More info: https://docs.docker.com/go/dockerfile/rule/stage-name-casing/
WORKDIR /repo/
COPY playground/ ./
RUN npm install --legacy-peer-deps
Expand All @@ -11,7 +11,7 @@

# Stage: BUILD
# Several steps are involved to enable caching and because of the behavior of COPY regarding directories.
FROM docker.io/golang:1.21 AS BUILD
FROM docker.io/golang:1.22 AS BUILD

Check warning on line 14 in tools/defradb.containerfile

View workflow job for this annotation

GitHub Actions / Validate containerfile job

Stage names should be lowercase

StageNameCasing: Stage name 'BUILD' should be lowercase More info: https://docs.docker.com/go/dockerfile/rule/stage-name-casing/

Check warning on line 14 in tools/defradb.containerfile

View workflow job for this annotation

GitHub Actions / Validate containerfile job

Stage names should be lowercase

StageNameCasing: Stage name 'BUILD' should be lowercase More info: https://docs.docker.com/go/dockerfile/rule/stage-name-casing/
WORKDIR /repo/
COPY go.mod go.sum Makefile ./
RUN make deps:modules
Expand Down
Loading