-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use native go method to get current user rather than environment variable #4930
Conversation
Blocked until 1.6.0-rc1 is released |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good just need a little change.
Codecov Report
@@ Coverage Diff @@
## master #4930 +/- ##
=========================================
+ Coverage 37.4% 37.4% +<.01%
=========================================
Files 306 306
Lines 45378 45389 +11
=========================================
+ Hits 16974 16980 +6
- Misses 25949 25954 +5
Partials 2455 2455
Continue to review full report at Codecov.
|
Fixes #1640, #4894
Native "os/user" go package has good function to retrieve current user, rather than relying on USER environment variable.
If getting current user doesn't work on target OS (for example, not yet implemented for it) - it falls back to old implementation with environment variables.
Unit test also changed, old one won't work because USER environment variable spoofing doesn't work anymore (unless os/user is not implemented for OS under which tests are run), now it just compares CurrentUser() with
whoami
command output (skipped on Windows where whoami behaves different way).For Windows OS with "domain\username" format, only second part (username) is returned to match previous behavior and trim unnecessary prefix.