8000 chore: update golang to 1.24.1 by sreya · Pull Request #17035 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

chore: update golang to 1.24.1 #17035

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 42 commits into from
Mar 26, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
5df49f9
feat: update Go version to 1.24.1
Mar 21, 2025
83e79be
refactor: simplify Go 1.24.1 update
Mar 21, 2025
57a47e0
revert: simplify change to go version only
Mar 21, 2025
8187c9e
fix: update guts dependency to support Go 1.24.1
Mar 21, 2025
5aaf404
fix: update golangci-lint tool for Go 1.24.1
Mar 21, 2025
d7160ae
fix: temporarily disable Go linting due to Go 1.24.1 compatibility is…
Mar 21, 2025
3c3aa21
fix: update golangci-lint to v1.57.1 for Go 1.24.1 compatibility
Mar 21, 2025
4710808
fix: upgrade golangci-lint to v1.64.8
Mar 21, 2025
2bcb38a
revert: restore original lint/go implementation in Makefile
Mar 21, 2025
651d489
fix: restore original Makefile structure with continue-on-error for l…
Mar 21, 2025
77b2908
chore: remove continue-on-error behavior from lint/go
Mar 21, 2025
226e838
update golangci rules
sreya Mar 24, 2025
02fd64a
fix config
sreya Mar 24, 2025
3d07833
ignore unused parameters in tests
sreya Mar 25, 2025
75be2c3
update golangci rules
sreya Mar 25, 2025
2b19287
more updates
sreya Mar 25, 2025
ee44d98
fix: Add #nosec G115 annotations to address integer overflow conversi…
sreya Mar 25, 2025
f8af6a8
fix: Add more #nosec G115 annotations for integer overflow warnings
sreya Mar 25, 2025
3cf7102
fix: address G115 integer overflow linter warnings for Go 1.24.1
sreya Mar 25, 2025
527df65
fix: address more G115 integer overflow linter warnings
sreya Mar 25, 2025
7d11352
refactor: replace if-else chains with switch statements
sreya Mar 25, 2025
59e1b9c
fix: resolve unused parameter linter issues for Go 1.24.1 compatibility
sreya Mar 25, 2025
bb5aa17
fix: resolve unused-parameter warnings for Go 1.24.1 compatibility
sreya Mar 26, 2025
0b3571a
errname and fix changes
sreya Mar 26, 2025
7f93228
more fixes
sreya Mar 26, 2025
792b4b5
fix compilation error
sreya Mar 26, 2025
a4f441a
fix: resolve G115 integer overflow conversion warnings for Go 1.24.1 …
sreya Mar 26, 2025
5caf54d
fix: convert if-else chains to switch statements for Go 1.24.1 compat…
sreya Mar 26, 2025
d9b665c
fix abhorrent edits
sreya Mar 26, 2025
7e0ceec
fix more linting rules
sreya Mar 26, 2025
1530bfb
fix agent
sreya Mar 26, 2025
9ae5514
fix more stuff
sreya Mar 26, 2025
e2e1e17
fix test
sreya Mar 26, 2025
f3f5755
fix: resolve remaining redefines-builtin-id linting issues
sreya Mar 26, 2025
9b0a218
fix appendAssign
sreya Mar 26, 2025
d3581a8
fix: resolve deferUnlambda linting issues by simplifying defer statem…
sreya Mar 26, 2025
1bb7942
fix ifelse
sreya Mar 26, 2025
31311d3
fix assignOp linting errors
Mar 26, 2025
3b93057
Revert "fix: resolve deferUnlambda linting issues by simplifying defe…
sreya Mar 26, 2025
3a4ac1e
unlambda && make gen
sreya Mar 26, 2025
38de0cf
don't commit dbmock
sreya Mar 26, 2025
3afeb90
make gen
sreya Mar 26, 2025
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
Prev Previous commit
Next Next commit
fix more linting rules
  • Loading branch information
sreya committed Mar 26, 2025
commit 7e0ceec0cec65cc37aabeb1ed2150e0167c2bdb2
6 changes: 3 additions & 3 deletions cli/remoteforward.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func validateRemoteForward(flag string) bool {
return isRemoteForwardTCP(flag) || isRemoteForwardUnixSocket(flag)
}

func parseRemoteForwardTCP(matches []string) (net.Addr, net.Addr, error) {
func parseRemoteForwardTCP(matches []string) (local net.Addr, remote net.Addr, err error) {
remotePort, err := strconv.Atoi(matches[1])
if err != nil {
return nil, nil, xerrors.Errorf("remote port is invalid: %w", err)
Expand Down Expand Up @@ -69,7 +69,7 @@ func parseRemoteForwardTCP(matches []string) (net.Addr, net.Addr, error) {
// parseRemoteForwardUnixSocket parses a remote forward flag. Note that
// we don't verify that the local socket path exists because the user
// may create it later. This behavior matches OpenSSH.
func parseRemoteForwardUnixSocket(matches []string) (net.Addr, net.Addr, error) {
func parseRemoteForwardUnixSocket(matches []string) (local net.Addr, remote net.Addr, err error) {
remoteSocket := matches[1]
localSocket := matches[2]

Expand All @@ -85,7 +85,7 @@ func parseRemoteForwardUnixSocket(matches []string) (net.Addr, net.Addr, error)
return localAddr, remoteAddr, nil
}

func parseRemoteForward(flag string) (net.Addr, net.Addr, error) {
func parseRemoteForward(flag string) (local net.Addr, remote net.Addr, err error) {
tcpMatches := remoteForwardRegexTCP.FindStringSubmatch(flag)

if len(tcpMatches) > 0 {
Expand Down
6 changes: 3 additions & 3 deletions cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,14 @@ func (r *RootCmd) RunWithSubcommands(subcommands []*serpent.Command) {
err = exitErr.err
}
if errors.Is(err, cliui.ErrCanceled) {
//nolint:revive
//nolint:revive,gocritic
os.Exit(code)
}
f := PrettyErrorFormatter{w: os.Stderr, verbose: r.verbose}
if err != nil {
f.Format(err)
}
//nolint:revive
//nolint:revive,gocritic
os.Exit(code)
}
}
Expand Down Expand Up @@ -891,7 +891,7 @@ func DumpHandler(ctx context.Context, name string) {

done:
if sigStr == "SIGQUIT" {
//nolint:revive
//nolint:revive,gocritic
os.Exit(1)
}
}
Expand Down
1 change: 1 addition & 0 deletions cmd/coder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
)

func main() {
panic("hey")
if len(os.Args) > 1 && os.Args[1] == "agent-exec" {
err := agentexec.CLI()
_, _ = fmt.Fprintln(os.Stderr, err)
Expand Down
8 changes: 4 additions & 4 deletions coderd/database/dbauthz/dbauthz.go
Original file line number Diff line number Diff line change
Expand Up @@ -1663,8 +1663,8 @@ func (q *querier) GetDeploymentWorkspaceStats(ctx context.Context) (database.Get
return q.db.GetDeploymentWorkspaceStats(ctx)
}

func (q *querier) GetEligibleProvisionerDaemonsByProvisionerJobIDs(ctx context.Context, provisionerJobIds []uuid.UUID) ([]database.GetEligibleProvisionerDaemonsByProvisionerJobIDsRow, error) {
return fetchWithPostFilter(q.auth, policy.ActionRead, q.db.GetEligibleProvisionerDaemonsByProvisionerJobIDs)(ctx, provisionerJobIds)
func (q *querier) GetEligibleProvisionerDaemonsByProvisionerJobIDs(ctx context.Context, provisionerJobIDs []uuid.UUID) ([]database.GetEligibleProvisionerDaemonsByProvisionerJobIDsRow, error) {
return fetchWithPostFilter(q.auth, policy.ActionRead, q.db.GetEligibleProvisionerDaemonsByProvisionerJobIDs)(ctx, provisionerJobIDs)
}

func (q *querier) GetExternalAuthLink(ctx context.Context, arg database.GetExternalAuthLinkParams) (database.ExternalAuthLink, error) {
Expand Down Expand Up @@ -3017,11 +3017,11 @@ func (q *querier) GetWorkspaceResourcesCreatedAfter(ctx context.Context, created
return q.db.GetWorkspaceResourcesCreatedAfter(ctx, createdAt)
}

func (q *querier) GetWorkspaceUniqueOwnerCountByTemplateIDs(ctx context.Context, templateIds []uuid.UUID) ([]database.GetWorkspaceUniqueOwnerCountByTemplateIDsRow, error) {
func (q *querier) GetWorkspaceUniqueOwnerCountByTemplateIDs(ctx context.Context, templateIDs []uuid.UUID) ([]database.GetWorkspaceUniqueOwnerCountByTemplateIDsRow, error) {
if err := q.authorizeContext(ctx, policy.ActionRead, rbac.ResourceSystem); err != nil {
return nil, err
}
return q.db.GetWorkspaceUniqueOwnerCountByTemplateIDs(ctx, templateIds)
return q.db.GetWorkspaceUniqueOwnerCountByTemplateIDs(ctx, templateIDs)
}

func (q *querier) GetWorkspaces(ctx context.Context, arg database.GetWorkspacesParams) ([]database.GetWorkspacesRow, error) {
Expand Down
1 change: 1 addition & 0 deletions coderd/rbac/regosql/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func convertQuery(cfg ConvertConfig, q ast.Body) (sqltypes.BooleanNode, error) {

func convertExpression(< 9E81 span class=pl-s1>cfg ConvertConfig, e *ast.Expr) (sqltypes.BooleanNode, error) {
if e.IsCall() {
//nolint:forcetypeassert
n, err := convertCall(cfg, e.Terms.([]*ast.Term))
if err != nil {
return nil, xerrors.Errorf("call: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion coderd/util/tz/tz_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TimezoneIANA() (*time.Location, error) {
if err != nil {
return nil, xerrors.Errorf("read location of %s: %w", etcLocaltime, err)
}
stripped := strings.Replace(lp, zoneInfoPath, "", -1)
stripped := strings.ReplaceAll(lp, zoneInfoPath, "")
stripped = strings.TrimPrefix(stripped, string(filepath.Separator))
loc, err = time.LoadLocation(stripped)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion coderd/workspaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func TestWorkspace(t *testing.T) {
want = want[:32-5] + "-test"
}
// Sometimes truncated names result in `--test` which is not an allowed name.
want = strings.Replace(want, "--", "-", -1)
want = strings.ReplaceAll(want, "--", "-")
err := client.UpdateWorkspace(ctx, ws1.ID, codersdk.UpdateWorkspaceRequest{
Name: want,
})
Expand Down
2 changes: 1 addition & 1 deletion helm/provisioner/tests/chart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func TestRenderChart(t *testing.T) {
require.NoError(t, err, "failed to read golden file %q", goldenFilePath)

// Remove carriage returns to make tests pass on Windows.
goldenBytes = bytes.Replace(goldenBytes, []byte("\r"), []byte(""), -1)
goldenBytes = bytes.ReplaceAll(goldenBytes, []byte("\r"), []byte(""))
expected := string(goldenBytes)

require.NoError(t, err, "failed to load golden file %q")
Expand Down
13 changes: 0 additions & 13 deletions provisioner/terraform/provision_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"net/http"
"os"
"path/filepath"
"runtime"
"sort"
"strings"
"testing"
Expand Down Expand Up @@ -119,10 +118,6 @@ func sendApply(sess proto.DRPCProvisioner_SessionClient, transition proto.Worksp
// one process tries to do this simultaneously, it can cause "text file busy"
// nolint: paralleltest
func TestProvision_Cancel(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("This test uses interrupts and is not supported on Windows")
}

cwd, err := os.Getwd()
require.NoError(t, err)
fakeBin := filepath.Join(cwd, "testdata", "fake_cancel.sh")
Expand Down Expand Up @@ -215,10 +210,6 @@ func TestProvision_Cancel(t *testing.T) {
// one process tries to do this, it can cause "text file busy"
// nolint: paralleltest
func TestProvision_CancelTimeout(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("This test uses interrupts and is not supported on Windows")
}

cwd, err := os.Getwd()
require.NoError(t, err)
fakeBin := filepath.Join(cwd, "testdata", "fake_cancel_hang.sh")
Expand Down Expand Up @@ -278,10 +269,6 @@ func TestProvision_CancelTimeout(t *testing.T) {
// terraform-provider-coder
// nolint: paralleltest
func TestProvision_TextFileBusy(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("This test uses unix sockets and is not supported on Windows")
}

cwd, err := os.Getwd()
require.NoError(t, err)
fakeBin := filepath.Join(cwd, "testdata", "fake_text_file_busy.sh")
Expand Down
13 changes: 0 additions & 13 deletions provisioner/terraform/resources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1210,27 +1210,16 @@ func TestParameterValidation(t *testing.T) {
tfPlanGraph, err := os.ReadFile(filepath.Join(dir, "rich-parameters.tfplan.dot"))
require.NoError(t, err)

// Change all names to be identical.
var names []string
for _, resource := range tfPlan.PriorState.Values.RootModule.Resources {
if resource.Type == "coder_parameter" {
resource.AttributeValues["name"] = "identical"
names = append(names, resource.Name)
}
}

state, err := terraform.ConvertState(ctx, []*tfjson.StateModule{tfPlan.PriorState.Values.RootModule}, string(tfPlanGraph), logger)
require.Nil(t, state)
require.Error(t, err)
require.ErrorContains(t, err, "coder_parameter names must be unique but \"identical\" appears multiple times")

// Make two sets of identical names.
count := 0
names = nil
for _, resource := range tfPlan.PriorState.Values.RootModule.Resources {
if resource.Type == "coder_parameter" {
resource.AttributeValues["name"] = fmt.Sprintf("identical-%d", count%2)
names = append(names, resource.Name)
count++
}
}
Expand All @@ -1242,11 +1231,9 @@ func TestParameterValidation(t *testing.T) {

// Once more with three sets.
count = 0
names = nil
for _, resource := range tfPlan.PriorState.Values.RootModule.Resources {
if resource.Type == "coder_parameter" {
resource.AttributeValues["name"] = fmt.Sprintf("identical-%d", count%3)
names = append(names, resource.Name)
count++
}
}
Expand Down
5 changes: 2 additions & 3 deletions provisioner/terraform/tfparse/tfparse.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ func WriteArchive(bs []byte, mimetype string, path string) error {
return xerrors.Errorf("read zip file: %w", err)
} else if tarBytes, err := archive.CreateTarFromZip(zr, maxFileSizeBytes); err != nil {
return xerrors.Errorf("convert zip to tar: %w", err)
} else {
} else { //nolint:revive
rdr = bytes.NewReader(tarBytes)
}
default:
Expand Down Expand Up @@ -558,9 +558,8 @@ func CtyValueString(val cty.Value) (string, error) {
case cty.Bool:
if val.True() {
return "true", nil
} else {
return "false", nil
}
return "false", nil
case cty.Number:
return val.AsBigFloat().String(), nil
case cty.String:
Expand Down
8 changes: 4 additions & 4 deletions scripts/echoserver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ func main() {
defer l.Close()
tcpAddr, valid := l.Addr().(*net.TCPAddr)
if !valid {
log.Fatal("address is not valid")
log.Panic("address is not valid")
}

remotePort := tcpAddr.Port
_, err = fmt.Println(remotePort)
if err != nil {
log.Fatalf("print error: err=%s", err)
log.Panicf("print error: err=%s", err)
}

for {
conn, err := l.Accept()
if err != nil {
log.Fatalf("accept error, err=%s", err)
log.Panicf("accept error, err=%s", err)
return
}

Expand All @@ -43,7 +43,7 @@ func main() {
if errors.Is(err, io.EOF) {
return
} else if err != nil {
log.Fatalf("copy error, err=%s", err)
log.Panicf("copy error, err=%s", err)
}
}()
}
Expand Down
8 changes: 4 additions & 4 deletions scripts/migrate-test/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,25 +82,25 @@ func main() {
_, _ = fmt.Fprintf(os.Stderr, "Init database at version %q\n", migrateFromVersion)
if err := migrations.UpWithFS(conn, migrateFromFS); err != nil {
friendlyError(os.Stderr, err, migrateFromVersion, migrateToVersion)
os.Exit(1)
panic("")
Copy link
Member

Choose a reason for hiding this comment

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

This seems weird

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i guess panic(err) would be better?

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good

}

_, _ = fmt.Fprintf(os.Stderr, "Migrate to version %q\n", migrateToVersion)
if err := migrations.UpWithFS(conn, migrateToFS); err != nil {
friendlyError(os.Stderr, err, migrateFromVersion, migrateToVersion)
os.Exit(1)
panic("")
}

_, _ = fmt.Fprintf(os.Stderr, "Dump schema at version %q\n", migrateToVersion)
dumpBytesAfter, err := dbtestutil.PGDumpSchemaOnly(postgresURL)
if err != nil {
friendlyError(os.Stderr, err, migrateFromVersion, migrateToVersion)
os.Exit(1)
panic("")
}

if diff := cmp.Diff(string(dumpBytesAfter), string(stripGenPreamble(expectedSchemaAfter))); diff != "" {
friendlyError(os.Stderr, xerrors.Errorf("Schema differs from expected after migration: %s", diff), migrateFromVersion, migrateToVersion)
os.Exit(1)
panic("")
}
_, _ = fmt.Fprintf(os.Stderr, "OK\n")
}
Expand Down
0