Skip to content
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

refactor: apply goimports linter #332

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ linters:
# - gocritic
# - gofmt
- goheader
# - goimports
- goimports
- gomoddirectives
- gomodguard
- goprintffuncname
Expand Down
2 changes: 1 addition & 1 deletion artifact/image/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"strings"

"github.com/google/go-containerregistry/pkg/name"
"github.com/google/go-containerregistry/pkg/v1"
v1 "github.com/google/go-containerregistry/pkg/v1"
"github.com/google/go-containerregistry/pkg/v1/remote"
"github.com/google/osv-scalibr/artifact/image/require"
"github.com/google/osv-scalibr/artifact/image/unpack"
Expand Down
3 changes: 2 additions & 1 deletion artifact/image/layerscanning/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ import (
"strings"

"archive/tar"
"github.com/google/go-containerregistry/pkg/v1"

v1 "github.com/google/go-containerregistry/pkg/v1"
"github.com/google/go-containerregistry/pkg/v1/remote"
"github.com/google/go-containerregistry/pkg/v1/tarball"
scalibrImage "github.com/google/osv-scalibr/artifact/image"
Expand Down
2 changes: 1 addition & 1 deletion artifact/image/tar/tar.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"os"
"strings"

"github.com/google/go-containerregistry/pkg/v1"
v1 "github.com/google/go-containerregistry/pkg/v1"
"github.com/google/go-containerregistry/pkg/v1/mutate"
"github.com/google/osv-scalibr/log"
)
Expand Down
2 changes: 1 addition & 1 deletion artifact/image/tar/tar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/google/go-containerregistry/pkg/v1"
v1 "github.com/google/go-containerregistry/pkg/v1"
"github.com/google/go-containerregistry/pkg/v1/tarball"
"github.com/google/osv-scalibr/artifact/image/tar"
)
Expand Down
3 changes: 2 additions & 1 deletion artifact/image/unpack/unpack.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ import (
"strings"

"archive/tar"
"github.com/google/go-containerregistry/pkg/v1"

v1 "github.com/google/go-containerregistry/pkg/v1"
"github.com/google/osv-scalibr/artifact/image/require"
"github.com/google/osv-scalibr/artifact/image/symlink"
scalibrtar "github.com/google/osv-scalibr/artifact/image/tar"
Expand Down
3 changes: 2 additions & 1 deletion artifact/image/unpack/unpack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ import (
"testing"

"archive/tar"

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/google/go-containerregistry/pkg/v1"
v1 "github.com/google/go-containerregistry/pkg/v1"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not quite sure if I understand why it's better formatting to make things ending with "v1" a named import?

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 was curious about that myself but unfortunately I couldn't find a concrete laymen answer, just the issue that lead to it being a thing.

From what I could tell, something has an issue with implicitly-named imports of versions like this maybe because of special handling Go has for major versions of packages, and that resulted in something erroring - I think it might be a technical edge case in goimports rather than an actual language constraint, and that they decided it was fine to just make the convention to explicitly define the package name in this case?

"github.com/google/go-containerregistry/pkg/v1/empty"
"github.com/google/go-containerregistry/pkg/v1/mutate"
"github.com/google/go-containerregistry/pkg/v1/tarball"
Expand Down
1 change: 1 addition & 0 deletions detector/weakcredentials/winlocal/samreg/samreg.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package samreg

import (
"fmt"

"github.com/google/osv-scalibr/common/windows/registry"
)

Expand Down
Loading