Skip to content

Commit

Permalink
refactor: minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Dec 30, 2024
1 parent 57dedbb commit 9eb217f
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions exptostd.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ func (a *analyzer) run(pass *analysis.Pass) (any, error) {
}
})

a.maybeReplaceImport(pass, imports, shouldKeepExpMaps, shouldKeepExpSlices)
a.suggestReplaceImport(pass, imports, shouldKeepExpMaps, "golang.org/x/exp/maps")
a.suggestReplaceImport(pass, imports, shouldKeepExpSlices, "golang.org/x/exp/slices")

return nil, nil
}
Expand Down Expand Up @@ -204,13 +205,6 @@ func (a *analyzer) detectPackageUsage(pass *analysis.Pass,
return false
}

func (a *analyzer) maybeReplaceImport(pass *analysis.Pass, imports map[string]*ast.ImportSpec,
shouldKeepExpMaps, shouldKeepExpSlices bool,
) {
a.suggestReplaceImport(pass, imports, shouldKeepExpMaps, "golang.org/x/exp/maps")
a.suggestReplaceImport(pass, imports, shouldKeepExpSlices, "golang.org/x/exp/slices")
}

func (a *analyzer) suggestReplaceImport(pass *analysis.Pass, imports map[string]*ast.ImportSpec, shouldKeep bool, importPath string) {
imp, ok := imports[importPath]
if !ok || shouldKeep {
Expand Down

0 comments on commit 9eb217f

Please sign in to comment.