mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-13 09:57:51 +08:00
Replace "USERNAME" literals with a constant
This commit is contained in:
parent
a4e539c823
commit
30d1161ded
|
@ -4,12 +4,14 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/elves/elvish/pkg/util"
|
||||
)
|
||||
|
||||
// getSecureRunDir stats elvish-$USERNAME under the default temp dir, creating
|
||||
// it if it doesn't yet exist, and return the directory name.
|
||||
func getSecureRunDir() (string, error) {
|
||||
username := os.Getenv("USERNAME")
|
||||
username := os.Getenv(util.EnvUSERNAME)
|
||||
|
||||
runDir := filepath.Join(os.TempDir(), "elvish-"+username)
|
||||
err := os.MkdirAll(runDir, 0700)
|
||||
|
|
|
@ -6,12 +6,13 @@ package util
|
|||
// Note that some of these env vars may be significant only in special
|
||||
// circumstances; such as when running unit tests.
|
||||
const (
|
||||
EnvELVISH_TEST_TIME_SCALE = "ELVISH_TEST_TIME_SCALE"
|
||||
EnvHOME = "HOME"
|
||||
EnvLS_COLORS = "LS_COLORS"
|
||||
EnvPATH = "PATH"
|
||||
EnvPATHEXT = "PATHEXT"
|
||||
EnvPWD = "PWD"
|
||||
EnvSHLVL = "SHLVL"
|
||||
EnvLS_COLORS = "LS_COLORS"
|
||||
EnvUSERNAME = "USERNAME"
|
||||
EnvXDG_RUNTIME_DIR = "XDG_RUNTIME_DIR"
|
||||
EnvELVISH_TEST_TIME_SCALE = "ELVISH_TEST_TIME_SCALE"
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue
Block a user