Skip to content

chore: Update to Go 1.24.6 and Go linter to 2.3.1 #3579

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

Merged
merged 4 commits into from
Aug 12, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/code-health.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9
with:
version: v2.1.6 # Also update GOLANGCI_VERSION variable in GNUmakefile when updating this version
version: v2.3.1 # Also update GOLANGCI_VERSION variable in GNUmakefile when updating this version
- name: actionlint
run: |
make tools
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ GITTAG=$(shell git describe --always --tags)
VERSION=$(GITTAG:v%=%)
LINKER_FLAGS=-s -w -X 'github.com/mongodb/terraform-provider-mongodbatlas/version.ProviderVersion=${VERSION}'

GOLANGCI_VERSION=v2.1.6 # Also update golangci-lint GH action in code-health.yml when updating this version
GOLANGCI_VERSION=v2.3.1 # Also update golangci-lint GH action in code-health.yml when updating this version

export PATH := $(shell go env GOPATH)/bin:$(PATH)
export SHELL := env PATH=$(PATH) /bin/bash
Expand Down Expand Up @@ -236,4 +236,4 @@ upload-sbom: ## Upload SBOM

.PHONY: augment-sbom
augment-sbom: ## Augment SBOM
./scripts/compliance/augment-sbom.sh
./scripts/compliance/augment-sbom.sh
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/mongodb/terraform-provider-mongodbatlas

go 1.24.5
go 1.24.6

require (
github.com/andygrunwald/go-jira/v2 v2.0.0-20240116150243-50d59fe116d6
Expand Down
4 changes: 2 additions & 2 deletions internal/serviceapi/clusterapi/resource_schema.go

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

2 changes: 1 addition & 1 deletion internal/serviceapi/projectapi/resource_schema.go

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

2 changes: 1 addition & 1 deletion internal/testutil/clean/org_clean_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func TestCleanProjectAndClusters(t *testing.T) {
})
}
t.Cleanup(func() {
projectsAfter := readAllProjects(context.Background(), t, client) //nolint:usetesting // reason: using context.Background() here intentionally because t.Context() is canceled at cleanup
projectsAfter := readAllProjects(context.Background(), t, client) // reason: using context.Background() here intentionally because t.Context() is canceled at cleanup
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix linter issue:

internal/testutil/clean/org_clean_test.go:145:69: directive `//nolint:usetesting // reason: using context.Background() here intentionally because t.Context() is canceled at cleanup` is unused for linter "usetesting" (nolintlint)

t.Logf("SUMMARY\nProjects changed from %d to %d\ndelete_errors=%d\nempty_project_count=%d\nDRY_RUN=%t", projectsBefore, len(projectsAfter), deleteErrors, emptyProjectCount, dryRun)
})
}
Expand Down
5 changes: 3 additions & 2 deletions tools/codegen/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"context"
"fmt"
"log"
"os"
Expand Down Expand Up @@ -75,12 +76,12 @@ func writeToFile(fileName, content string) error {

// formatGoFile runs goimports and fieldalignment on the specified Go file
func formatGoFile(filePath string) {
goimportsCmd := exec.Command("goimports", "-w", filePath)
goimportsCmd := exec.CommandContext(context.Background(), "goimports", "-w", filePath)
Copy link
Member Author

@lantoli lantoli Aug 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix linter issue:

os/exec.Command must not be called. use os/exec.CommandContext (noctx)

if output, err := goimportsCmd.CombinedOutput(); err != nil {
log.Printf("warning: goimports failed for %s: %v\nOutput: %s", filePath, err, output)
}

fieldalignmentCmd := exec.Command("fieldalignment", "-fix", filePath)
fieldalignmentCmd := exec.CommandContext(context.Background(), "fieldalignment", "-fix", filePath)
if output, err := fieldalignmentCmd.CombinedOutput(); err != nil {
log.Printf("warning: fieldalignment failed for %s: %v\nOutput: %s", filePath, err, output)
}
Expand Down