From 0c064b1b79bc5fe0558fb5ba1a185cfc27a77f75 Mon Sep 17 00:00:00 2001 From: ᴜɴᴋɴᴡᴏɴ Date: Mon, 24 Feb 2020 21:13:56 +0800 Subject: cmd/web: fix error when Unix socket not exists --- internal/osutil/osutil.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'internal/osutil/osutil.go') diff --git a/internal/osutil/osutil.go b/internal/osutil/osutil.go index 656f2e2a..827988a0 100644 --- a/internal/osutil/osutil.go +++ b/internal/osutil/osutil.go @@ -17,6 +17,12 @@ func IsFile(path string) bool { return !f.IsDir() } +// IsExist returns true if a file or directory exists. +func IsExist(path string) bool { + _, err := os.Stat(path) + return err == nil || os.IsExist(err) +} + // CurrentUsername returns the current system user via environment variables. func CurrentUsername() string { curUserName := os.Getenv("USER") -- cgit v1.2.3