-
Notifications
You must be signed in to change notification settings - Fork 819
-
Hi!
I have this annoying issue when organizing imports will always prefer slog from "golang.org/x/exp/slog"
instead of standard library. The go version in go.mod
states go 1.21.0
so I have a reason to believe that log/slog
should have priority in this case. I have no idea if this is a bug or configurable behavior, at least I have not found anything related to specific preferences when it comes to package imports.
Any ideas or tips how to solve this?
Beta Was this translation helpful? Give feedback.
All reactions
@jurisevo
You can handle this in two ways:
On VS Code, add this to your settings.json
:
{ "gopls": { "importShortcut": "Definition" } }
Alternatively, you can remove the experimental package by running go get -d golang.org/x/exp/slog@none
followed by go mod tidy
. This will clean up your dependencies and force the usage of the standard library version from log/slog
. Make sure to update your imports from golang.org/x/exp/slog
to log/slog
in your code.
Replies: 1 comment
-
@jurisevo
You can handle this in two ways:
On VS Code, add this to your settings.json
:
{ "gopls": { "importShortcut": "Definition" } }
Alternatively, you can remove the experimental package by running go get -d golang.org/x/exp/slog@none
followed by go mod tidy
. This will clean up your dependencies and force the usage of the standard library version from log/slog
. Make sure to update your imports from golang.org/x/exp/slog
to log/slog
in your code.
Beta Was this translation helpful? Give feedback.