Skip to content

Commit

Permalink
switch golang.org/x/exp/slices usages to stdlib
Browse files Browse the repository at this point in the history
As of Go 1.21, golang.org/x/exp/slices is now in the standard library as slices.
A similar conversion can be done for golang.org/x/exp/maps in Go 1.22, dependent on maps.Keys.

Signed-off-by: Spencer Schrock <[email protected]>
  • Loading branch information
spencerschrock committed Dec 5, 2023
1 parent 56a6590 commit c1b9ed1
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cmd/osv-scanner/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import (
"fmt"
"io"
"os"
"slices"
"strings"

"github.com/google/osv-scanner/internal/version"
"github.com/google/osv-scanner/pkg/osv"
"github.com/google/osv-scanner/pkg/osvscanner"
"github.com/google/osv-scanner/pkg/reporter"
"golang.org/x/exp/slices"
"golang.org/x/term"

"github.com/urfave/cli/v2"
Expand Down
3 changes: 2 additions & 1 deletion internal/ci/vulnerability_result_diff.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package ci

import (
"slices"

"github.com/google/osv-scanner/pkg/grouper"
"github.com/google/osv-scanner/pkg/models"
"golang.org/x/exp/slices"
)

// DiffVulnerabilityResults will return any new vulnerabilities that are in `newRes`
Expand Down
3 changes: 1 addition & 2 deletions internal/output/identifiers_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package output

import (
"slices"
"testing"

"golang.org/x/exp/slices"
)

func Test_idSortFunc(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion internal/output/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package output

import (
"encoding/json"
"slices"

"github.com/google/osv-scanner/pkg/models"
"golang.org/x/exp/slices"
)

type pkgWithSource struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/output/sarif.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"io"
"log"
"path/filepath"
"slices"
"strings"
"text/template"

Expand All @@ -15,7 +16,6 @@ import (
"github.com/jedib0t/go-pretty/v6/table"
"github.com/owenrumney/go-sarif/v2/sarif"
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
)

type HelpTemplateData struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/utility/vulns/vulnerability.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package vulns
import (
"fmt"
"os"
"slices"
"sort"

"github.com/google/osv-scanner/internal/semantic"
"github.com/google/osv-scanner/pkg/lockfile"
"github.com/google/osv-scanner/pkg/models"
"golang.org/x/exp/slices"
)

func eventVersion(e models.Event) string {
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"fmt"
"os"
"path/filepath"
"slices"
"time"

"github.com/BurntSushi/toml"
"github.com/google/osv-scanner/pkg/reporter"
"golang.org/x/exp/slices"
)

const osvScannerConfigName = "osv-scanner.toml"
Expand Down
2 changes: 1 addition & 1 deletion pkg/grouper/grouper.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package grouper

import (
"slices"
"sort"

"golang.org/x/exp/maps"
"golang.org/x/exp/slices"

"github.com/google/osv-scanner/pkg/models"
)
Expand Down
3 changes: 1 addition & 2 deletions pkg/models/results.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package models

import (
"slices"
"strings"

"golang.org/x/exp/slices"
)

// Combined vulnerabilities found for the scanned packages
Expand Down

0 comments on commit c1b9ed1

Please sign in to comment.