go-nv / goenv

:blue_car: Like pyenv and rbenv, but for Go.

Home Page:https://github.com/go-nv/goenv

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Option `--bare` in `goenv versions` return OK status code when no versions are installed

vicmattos opened this issue · comments

I'm at a MacBook Pro with Intel processor and zsh.

Both zsh and goenv are managed by homebrew:

.dotfiles % brew info zsh
zsh: stable 5.8.1 (bottled), HEAD
UNIX shell (command interpreter)
https://www.zsh.org/
/usr/local/Cellar/zsh/5.8.1 (1,531 files, 14.8MB) *
  Poured from bottle on 2022-02-14 at 16:44:48
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/zsh.rb
License: MIT-Modern-Variant
==> Dependencies
Required: ncurses ✔, pcre ✔
==> Options
--HEAD
        Install HEAD version
==> Analytics
install: 65,294 (30 days), 125,555 (90 days), 418,718 (365 days)
install-on-request: 61,364 (30 days), 115,599 (90 days), 384,499 (365 days)
build-error: 3 (30 days)

.dotfiles % brew info goenv
goenv: stable 1.23.3 (bottled), HEAD
Go version management
https://github.com/syndbg/goenv
/usr/local/Cellar/goenv/1.23.3 (158 files, 265.2KB) *
  Poured from bottle on 2022-03-03 at 16:08:16
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/goenv.rb
License: MIT
==> Options
--HEAD
        Install HEAD version
==> Analytics
install: 1,022 (30 days), 2,789 (90 days), 10,779 (365 days)
install-on-request: 1,021 (30 days), 2,793 (90 days), 10,776 (365 days)
build-error: 0 (30 days)

I have no go version installed yet the command goenv versions --bare still return OK:

.dotfiles % goenv versions
Warning: no Go detected on the system

.dotfiles % goenv versions --bare

.dotfiles % echo $?
0

This is consistent with rbenv/pyenv and friends -- what use case do you have for this? Is test -z "$(goenv versions --bare)" not a good solution for your purposes?

It would be a pretty easy fix to change this behavior, but I'm not sure a breaking change like this is a good idea if existing techniques work.

There was a PR to print better messages if no go matching go versions found. See PR #273