1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #40647 from thaJeztah/simplify_is_abs

pkg/system: minor linting issues and refactor
This commit is contained in:
Kir Kolyshkin 2020-03-11 10:52:49 -07:00 committed by GitHub
commit 26f8c7de91
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 7 deletions

View file

@ -130,12 +130,10 @@ func mkdirWithACL(name string, sddl string) error {
// by the daemon. This SHOULD be treated as absolute from a docker processing
// perspective.
func IsAbs(path string) bool {
if !filepath.IsAbs(path) {
if !strings.HasPrefix(path, string(os.PathSeparator)) {
return false
}
if filepath.IsAbs(path) || strings.HasPrefix(path, string(os.PathSeparator)) {
return true
}
return true
return false
}
// The origin of the functions below here are the golang OS and windows packages,

View file

@ -12,7 +12,7 @@ import (
func TestCheckSystemDriveAndRemoveDriveLetter(t *testing.T) {
// Fails if not C drive.
_, err := CheckSystemDriveAndRemoveDriveLetter(`d:\`, pathdriver.LocalPathDriver)
if err == nil || (err != nil && err.Error() != "The specified path is not on the system drive (C:)") {
if err == nil || err.Error() != "The specified path is not on the system drive (C:)" {
t.Fatalf("Expected error for d:")
}

View file

@ -13,6 +13,6 @@ func IsProcessAlive(pid int) bool {
func KillProcess(pid int) {
p, err := os.FindProcess(pid)
if err == nil {
p.Kill()
_ = p.Kill()
}
}