From 1efe0ebc5973ec8a06b881c087dae2183898504b Mon Sep 17 00:00:00 2001 From: Dean Deng Date: Wed, 13 Jan 2021 15:10:03 -0800 Subject: Switch uses of os.Getenv that check for empty string to os.LookupEnv. Whether the variable was found is already returned by syscall.Getenv. os.Getenv drops this value while os.Lookupenv passes it along. PiperOrigin-RevId: 351674032 --- runsc/cmd/gofer_test.go | 7 +++---- runsc/config/flags.go | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'runsc') diff --git a/runsc/cmd/gofer_test.go b/runsc/cmd/gofer_test.go index cbea7f127..fea62a4f4 100644 --- a/runsc/cmd/gofer_test.go +++ b/runsc/cmd/gofer_test.go @@ -24,11 +24,10 @@ import ( ) func tmpDir() string { - dir := os.Getenv("TEST_TMPDIR") - if dir == "" { - dir = "/tmp" + if dir, ok := os.LookupEnv("TEST_TMPDIR"); ok { + return dir } - return dir + return "/tmp" } type dir struct { diff --git a/runsc/config/flags.go b/runsc/config/flags.go index 02ab9255a..7e738dfdf 100644 --- a/runsc/config/flags.go +++ b/runsc/config/flags.go @@ -114,7 +114,7 @@ func NewFromFlags() (*Config, error) { if len(conf.RootDir) == 0 { // If not set, set default root dir to something (hopefully) user-writeable. conf.RootDir = "/var/run/runsc" - if runtimeDir := os.Getenv("XDG_RUNTIME_DIR"); runtimeDir != "" { + if runtimeDir, ok := os.LookupEnv("XDG_RUNTIME_DIR"); ok { conf.RootDir = filepath.Join(runtimeDir, "runsc") } } -- cgit v1.2.3