From b7fa75d7f82a6816d307805ac07e6965c799e938 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90=E1=BB=97=20Tr=E1=BB=8Dng=20H=E1=BA=A3i?= <41283691+hainenber@users.noreply.github.com> Date: Thu, 21 Sep 2023 01:38:37 +0700 Subject: [PATCH] chore: switch to stdlib's slices pkg (#2148) * chore: switch to stdlib's slices pkg Signed-off-by: hainenber * fix linting Signed-off-by: Alex Goodman --------- Signed-off-by: hainenber Signed-off-by: Alex Goodman Co-authored-by: Alex Goodman --- cmd/syft/cli/options/output.go | 3 +-- go.mod | 1 - go.sum | 2 -- syft/formats/common/cyclonedxhelpers/format.go | 2 +- syft/formats/common/spdxhelpers/to_format_model.go | 9 ++++++--- syft/formats/formats.go | 3 +-- syft/internal/fileresolver/unindexed_directory.go | 2 +- .../common/cpe/dictionary/index-generator/generate.go | 2 +- syft/pkg/cataloger/package_exclusions.go | 2 +- syft/sbom/sbom.go | 3 +-- 10 files changed, 13 insertions(+), 16 deletions(-) diff --git a/cmd/syft/cli/options/output.go b/cmd/syft/cli/options/output.go index 1c321fd47..034742757 100644 --- a/cmd/syft/cli/options/output.go +++ b/cmd/syft/cli/options/output.go @@ -2,8 +2,7 @@ package options import ( "fmt" - - "golang.org/x/exp/slices" + "slices" "github.com/anchore/clio" "github.com/anchore/syft/syft/formats" diff --git a/go.mod b/go.mod index 519cc967f..afec93164 100644 --- a/go.mod +++ b/go.mod @@ -69,7 +69,6 @@ require ( github.com/wagoodman/go-progress v0.0.0-20230911172108-cf810b7e365c github.com/xeipuuv/gojsonschema v1.2.0 github.com/zyedidia/generic v1.2.2-0.20230320175451-4410d2372cb1 - golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 golang.org/x/mod v0.12.0 golang.org/x/net v0.15.0 golang.org/x/term v0.12.0 // indirect diff --git a/go.sum b/go.sum index 1a62bed16..d29f143f7 100644 --- a/go.sum +++ b/go.sum @@ -855,8 +855,6 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 h1:m64FZMko/V45gv0bNmrNYoDEq8U5YUhetc9cBWKS1TQ= -golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63/go.mod h1:0v4NqG35kSWCMzLaMeX+IQrlSnVE/bqGSyC2cz/9Le8= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= diff --git a/syft/formats/common/cyclonedxhelpers/format.go b/syft/formats/common/cyclonedxhelpers/format.go index 4c06a4333..f99e826d3 100644 --- a/syft/formats/common/cyclonedxhelpers/format.go +++ b/syft/formats/common/cyclonedxhelpers/format.go @@ -1,12 +1,12 @@ package cyclonedxhelpers import ( + "slices" "strings" "time" "github.com/CycloneDX/cyclonedx-go" "github.com/google/uuid" - "golang.org/x/exp/slices" "github.com/anchore/syft/internal/log" "github.com/anchore/syft/syft/artifact" diff --git a/syft/formats/common/spdxhelpers/to_format_model.go b/syft/formats/common/spdxhelpers/to_format_model.go index e15d78d4f..ca6a4f730 100644 --- a/syft/formats/common/spdxhelpers/to_format_model.go +++ b/syft/formats/common/spdxhelpers/to_format_model.go @@ -5,14 +5,13 @@ import ( "crypto/sha1" "fmt" "path" + "slices" "sort" "strings" "time" "github.com/docker/distribution/reference" "github.com/spdx/tools-golang/spdx" - "golang.org/x/exp/maps" - "golang.org/x/exp/slices" "github.com/anchore/packageurl-go" "github.com/anchore/syft/internal" @@ -722,7 +721,11 @@ func toOtherLicenses(catalog *pkg.Collection) []*spdx.OtherLicense { var result []*spdx.OtherLicense - ids := maps.Keys(licenses) + var ids []string + for licenseID := range licenses { + ids = append(ids, licenseID) + } + slices.Sort(ids) for _, id := range ids { license := licenses[id] diff --git a/syft/formats/formats.go b/syft/formats/formats.go index b61027ed4..e18b1a852 100644 --- a/syft/formats/formats.go +++ b/syft/formats/formats.go @@ -6,10 +6,9 @@ import ( "fmt" "io" "regexp" + "slices" "strings" - "golang.org/x/exp/slices" - "github.com/anchore/syft/internal/log" "github.com/anchore/syft/syft/formats/cyclonedxjson" "github.com/anchore/syft/syft/formats/cyclonedxxml" diff --git a/syft/internal/fileresolver/unindexed_directory.go b/syft/internal/fileresolver/unindexed_directory.go index 31e888913..68fdd7965 100644 --- a/syft/internal/fileresolver/unindexed_directory.go +++ b/syft/internal/fileresolver/unindexed_directory.go @@ -6,6 +6,7 @@ import ( "io/fs" "os" "path" + "slices" "sort" "strings" "time" @@ -13,7 +14,6 @@ import ( "github.com/bmatcuk/doublestar/v4" "github.com/mitchellh/go-homedir" "github.com/spf13/afero" - "golang.org/x/exp/slices" "github.com/anchore/syft/internal/log" "github.com/anchore/syft/syft/file" diff --git a/syft/pkg/cataloger/common/cpe/dictionary/index-generator/generate.go b/syft/pkg/cataloger/common/cpe/dictionary/index-generator/generate.go index 30ba79ffc..c0de14ba5 100644 --- a/syft/pkg/cataloger/common/cpe/dictionary/index-generator/generate.go +++ b/syft/pkg/cataloger/common/cpe/dictionary/index-generator/generate.go @@ -7,10 +7,10 @@ import ( "fmt" "io" "log" + "slices" "strings" "github.com/facebookincubator/nvdtools/wfn" - "golang.org/x/exp/slices" "github.com/anchore/syft/syft/pkg/cataloger/common/cpe/dictionary" ) diff --git a/syft/pkg/cataloger/package_exclusions.go b/syft/pkg/cataloger/package_exclusions.go index f99e088fc..c9d67dd61 100644 --- a/syft/pkg/cataloger/package_exclusions.go +++ b/syft/pkg/cataloger/package_exclusions.go @@ -1,7 +1,7 @@ package cataloger import ( - "golang.org/x/exp/slices" + "slices" "github.com/anchore/syft/syft/artifact" "github.com/anchore/syft/syft/pkg" diff --git a/syft/sbom/sbom.go b/syft/sbom/sbom.go index f95df0955..18058255b 100644 --- a/syft/sbom/sbom.go +++ b/syft/sbom/sbom.go @@ -1,10 +1,9 @@ package sbom import ( + "slices" "sort" - "golang.org/x/exp/slices" - "github.com/anchore/syft/internal/log" "github.com/anchore/syft/syft/artifact" "github.com/anchore/syft/syft/file"