matchai / spacefish

πŸš€πŸŸ The fish shell prompt for astronauts
https://spacefish.matchai.dev
MIT License
960 stars 78 forks source link

(Go) unexpected argument at index 2 with two items in GOPATH #157

Closed 0xd3e closed 5 years ago

0xd3e commented 5 years ago

Bug Report

Current Behavior I have two items in the GOPATH variable, which has the benefit, that packages downloaded via go get are placed in the path of the first item and my own packages belong to the second item. You can read more about this here.

You'll see the following when opening the shell.

Last login: Sat Feb 16 20:48:02 on ttys002
Welcome to fish, the friendly interactive shell
[: unexpected argument at index 2: '/Users/danieltrautmann/Development/Projects'

~ ➜

go env

~ ➜ go env | grep GOPATH
GOPATH="/Users/danieltrautmann/Development/Go:/Users/danieltrautmann/Development/Projects"

variable content

~ ➜ echo $GOPATH
/Users/danieltrautmann/Development/Go /Users/danieltrautmann/Development/Projects

Expected Behavior I'd expect no error message at all.

Relevant Fish Configuration

_~/.config/fish/conf.d/04go.fish

set -gx GOPATH $HOME/Development/Go $HOME/Development/Projects
set -gx GO111MODULE off

_~/.config/fish/conf.d/99prompt.fish

set SPACEFISH_PROMPT_ORDER exit_code kubecontext golang pyenv git dir char

Environment

Possible Solution I figured out that [ -n $GOPATH ] in ~/.config/fish/functions/__sf_section_golang.fish is causing this and fixed it by replacing it with [ (count $GOPATH) -gt 0 ].

Now the prompt looks like the following.

~ ➜ cd ~/Development/Go/src/github.com/spf13/cobra/

🐹 v1.11.5 on ξ‚  master in cobra ➜ cd ~/Development/Projects/src/github.com/danieltrautmann/httpstat/

🐹 v1.11.5 on ξ‚  csv-output [!?] in httpstat ➜
matchai commented 5 years ago

:tada: This issue has been resolved in version 2.2.4 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: