-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
main: fix definition and implementation of relative GOHACK (#49)
rogpeppe has a far sharper brain than me and pointed out a major issue with the previous implementation: that we hadn't actually implemented a relative value of GOHACK relative to the main module.
- Loading branch information
Showing
12 changed files
with
275 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// +build !go1.12 | ||
|
||
package main | ||
|
||
import ( | ||
"errors" | ||
"os" | ||
"runtime" | ||
) | ||
|
||
// UserHomeDir was introduced in Go 1.12. When we drop support for Go 1.11, we can | ||
// lose this file. | ||
|
||
// UserHomeDir returns the current user's home directory. | ||
// | ||
// On Unix, including macOS, it returns the $HOME environment variable. | ||
// On Windows, it returns %USERPROFILE%. | ||
// On Plan 9, it returns the $home environment variable. | ||
func UserHomeDir() (string, error) { | ||
env, enverr := "HOME", "$HOME" | ||
switch runtime.GOOS { | ||
case "windows": | ||
env, enverr = "USERPROFILE", "%userprofile%" | ||
case "plan9": | ||
env, enverr = "home", "$home" | ||
case "nacl", "android": | ||
return "/", nil | ||
case "darwin": | ||
if runtime.GOARCH == "arm" || runtime.GOARCH == "arm64" { | ||
return "/", nil | ||
} | ||
} | ||
if v := os.Getenv(env); v != "" { | ||
return v, nil | ||
} | ||
return "", errors.New(enverr + " is not defined") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// +build go1.12 | ||
|
||
package main | ||
|
||
import "os" | ||
|
||
// UserHomeDir was introduced in Go 1.12. When we drop support for Go 1.11, we can | ||
// lose this file. | ||
|
||
func UserHomeDir() (string, error) { | ||
return os.UserHomeDir() | ||
} |
Oops, something went wrong.
hi