Skip to content

Commit 452ee5e

Browse files
skittjasdel
andauthored
config: Update shared config loading to use os.UserHomeDir() (#1563)
Instead of hard-coding Windows and *nix environment variables, rely on os.UserHomeDir() to do the right thing. Ignore errors since those only happen in situations we don't care about (and didn't handle previously). Signed-off-by: Stephen Kitt <[email protected]> Co-authored-by: Jason Del Ponte <[email protected]>
1 parent 484478f commit 452ee5e

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"id": "4f325261-c632-499c-b3f4-464799763f58",
3+
"type": "bugfix",
4+
"description": "Updates `config` module to use os.UserHomeDir instead of hard coded environment variable for OS. [#1563](https://github.com/aws/aws-sdk-go-v2/pull/1563)",
5+
"modules": [
6+
"config"
7+
]
8+
}

config/shared_config.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"fmt"
77
"os"
88
"path/filepath"
9-
"runtime"
109
"strings"
1110
"time"
1211

@@ -1051,12 +1050,9 @@ func (e CredentialRequiresARNError) Error() string {
10511050
}
10521051

10531052
func userHomeDir() string {
1054-
if runtime.GOOS == "windows" { // Windows
1055-
return os.Getenv("USERPROFILE")
1056-
}
1057-
1058-
// *nix
1059-
return os.Getenv("HOME")
1053+
// Ignore errors since we only care about Windows and *nix.
1054+
homedir, _ := os.UserHomeDir()
1055+
return homedir
10601056
}
10611057

10621058
func oneOrNone(bs ...bool) bool {

0 commit comments

Comments
 (0)