Skip to content

Commit

Permalink
fix(go dynenv): πŸ› consider empty GOPATH the same as unset GOPATH (#326)
Browse files Browse the repository at this point in the history
Go seems to consider an unset `GOPATH` the same as an empty-set
`GOPATH`. This can be observed with:

```
$ GOPATH= && go env | grep GOPATH
GOPATH='/Users/xaf/go'
$ unset GOPATH && go env | grep GOPATH
GOPATH='/Users/xaf/go'
```

This changes the dynamic environment to behave the same way when setting
the value of `GOMODCACHE`.
  • Loading branch information
XaF authored Jan 2, 2024
1 parent 78c425a commit aeb8516
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/internal/dynenv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,8 @@ impl DynamicEnv {
if std::env::var_os("GOMODCACHE").is_none() {
let gopath = match std::env::var_os("GOPATH") {
Some(gopath) => match gopath.to_str() {
Some("") | None => format!("{}/go", user_home()),
Some(gopath) => gopath.to_string(),
None => format!("{}/go", user_home()),
},
None => format!("{}/go", user_home()),
};
Expand Down

0 comments on commit aeb8516

Please sign in to comment.