asdf-community / asdf-golang

Go plugin for the asdf version manager
https://github.com/asdf-vm/asdf
MIT License
545 stars 92 forks source link

Not able to disable `ASDF_GOLANG_MOD_VERSION_ENABLED` #123

Open MPV opened 1 year ago

MPV commented 1 year ago

Describe the bug I have disabled ASDF_GOLANG_MOD_VERSION_ENABLED, but still getting the notice when starting my shell.

To Reproduce Steps to reproduce the behavior:

  1. Add export ASDF_GOLANG_MOD_VERSION_ENABLED=false in the shell's configs (.zshrc/equivalent).
  2. Start a new shell.

Expected behavior I should be able to disable the go.mod version detection (and just use .tool-versions for defining Golang version), without having my shell warning me about a feature I have decided to opt-out of.

Screenshots

Upon starting my shell:

Notice: Behaving like ASDF_GOLANG_MOD_VERSION_ENABLED=true
        In the future this will have to be set to continue
        reading from the go.mod and go.work files
$ env|grep ASDF_GOLANG_MOD_VERSION_ENABLED
ASDF_GOLANG_MOD_VERSION_ENABLED=false

Additional context

I'm using this version of the plugin:

$ asdf plugin list --refs | grep golang
golang                       master 3c3674a

i.e:

...which includes the change from:

i.e. this doesn't feel solved yet, in my mind:

Also, I think this other issue wouldn't be a bad idea:

zackerydev commented 9 months ago

@MPV make sure that line is the top of your .zshrc

I had mine below the asdf init and it wasn't working.

crcastle commented 9 months ago

I'm having a similar problem. Placing set ASDF_GOLANG_MOD_VERSION_ENABLED true above source (brew --prefix)/opt/asdf/libexec/asdf.fish in my (fish) shell configs stopped the warning message from appearing on every single prompt, but I continue to get the warning message any time I run go on the command line:

❯ go version
Notice: Behaving like ASDF_GOLANG_MOD_VERSION_ENABLED=true
        In the future this will have to be set to continue
        reading from the go.mod and go.work files
go version go1.20.13 darwin/arm64

~
❯ echo $ASDF_GOLANG_MOD_VERSION_ENABLED
true

~
❯  

Any ideas?

crcastle commented 9 months ago

Apologies for the last message, but I think I'll leave it in case someone runs into the same issue. Here's how I resolved it. Note that this only applies to the Fish shell.

Two options:

  1. Add set -gx ASDF_GOLANG_MOD_VERSION_ENABLED true to the top of /Users/crcastle/.config/fish/conf.d/asdf.fish. I mistakenly had left out the -gx when I wrote the comment above.
  2. Don't change any config files. Instead run set -Ux ASDF_GOLANG_MOD_VERSION_ENABLED true. This will save the env var persistently for any new shell (including after a restart).

I like option 1 better because it keeps asdf configuration in one place, the asdf.fish file.