github.com/april1989/origin-go-tools@v0.0.32/cmd/getgo/system_unix.go (about) 1 // Copyright 2017 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // +build aix darwin dragonfly freebsd linux nacl netbsd openbsd solaris 6 7 package main 8 9 import ( 10 "context" 11 "fmt" 12 "os" 13 "path/filepath" 14 ) 15 16 const ( 17 envSeparator = ":" 18 homeKey = "HOME" 19 lineEnding = "\n" 20 pathVar = "$PATH" 21 ) 22 23 var installPath = func() string { 24 home, err := getHomeDir() 25 if err != nil { 26 return "/usr/local/go" 27 } 28 29 return filepath.Join(home, ".go") 30 }() 31 32 func whichGo(ctx context.Context) (string, error) { 33 return findGo(ctx, "which") 34 } 35 36 func isWindowsXP() bool { 37 return false 38 } 39 40 func currentShell() string { 41 return os.Getenv("SHELL") 42 } 43 44 func persistEnvChangesForSession() error { 45 shellConfig, err := shellConfigFile() 46 if err != nil { 47 return err 48 } 49 fmt.Println() 50 fmt.Printf("One more thing! Run `source %s` to persist the\n", shellConfig) 51 fmt.Println("new environment variables to your current session, or open a") 52 fmt.Println("new shell prompt.") 53 54 return nil 55 }