Skip to content

Replace SA1019: parser.ParseDir #4089

@tlimoncelli

Description

@tlimoncelli

Hello friend!

@philpennock: Since you wrote the original code, would you consider fixing this?

Thanks!

Issue

lint is reporting that parser.ParseDir is deprecated:

$ golangci-lint run ./...
pkg/normalize/capabilities_test.go:24:15: SA1019: parser.ParseDir has been deprecated since Go 1.25 and an alternative has been available since Go 1.11: ParseDir does not consider build tags when associating files with packages. For precise information about the relationship between packages and files, use golang.org/x/tools/go/packages, which can also optionally parse and type-check the files too. (staticcheck)
	pkgs, err := parser.ParseDir(fset, providersImportDir, nil, 0)
	             ^

Resolution

Use golang.org/x/tools/go/packages instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions