Make caller path trimming Windows-compatible #385
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Go stdlib runtime.Caller() currently returns forward slashes on Windows (see golang/go#3335) which causes EntryCaller.TrimmedPath() to return full paths instead of the expected trimmed paths on Windows. This is because EntryCaller.TrimmedPath() uses os.PathSeparator to trim the path which is '' on Windows. According to the discussion on the Go bug, it seems like os.PathSeparator might be '' in some cases on Unix too so might cause issues on non-Windows platforms too.
This PR replaces the two occurrences of os.PathSeparator with ''/' as that is what runtime.Caller() currently produces on all platforms.
Did not add tests, as the existing tests for TrimmedPath() failed on Windows with master and work with this PR.
(TestOpen still fails on Windows but doesn't look like it's caused by this; Windows is returning errors in a different format than the test expects.)
make lint (ran from msys2 bash) fails (every single diff fails on every single line even though they look identical; maybe a newline issue?) but golint on entry.go is succesful.
Fixes: #382
See also: golang/go#18151
Before opening your pull request, please make sure that you've:
make test
); and finally,make lint
).Thanks for your contribution!