shared_config.go 1008 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package shareddefaults
  2. import (
  3. "os"
  4. "path/filepath"
  5. "runtime"
  6. )
  7. // SharedCredentialsFilename returns the SDK's default file path
  8. // for the shared credentials file.
  9. //
  10. // Builds the shared config file path based on the OS's platform.
  11. //
  12. // - Linux/Unix: $HOME/.aws/credentials
  13. // - Windows: %USERPROFILE%\.aws\credentials
  14. func SharedCredentialsFilename() string {
  15. return filepath.Join(UserHomeDir(), ".aws", "credentials")
  16. }
  17. // SharedConfigFilename returns the SDK's default file path for
  18. // the shared config file.
  19. //
  20. // Builds the shared config file path based on the OS's platform.
  21. //
  22. // - Linux/Unix: $HOME/.aws/config
  23. // - Windows: %USERPROFILE%\.aws\config
  24. func SharedConfigFilename() string {
  25. return filepath.Join(UserHomeDir(), ".aws", "config")
  26. }
  27. // UserHomeDir returns the home directory for the user the process is
  28. // running under.
  29. func UserHomeDir() string {
  30. if runtime.GOOS == "windows" { // Windows
  31. return os.Getenv("USERPROFILE")
  32. }
  33. // *nix
  34. return os.Getenv("HOME")
  35. }