mirror of
https://github.com/kevin-DL/revel-cmd.git
synced 2026-01-12 02:55:16 +00:00
Enhancements to Revel command
Reformat of code Allow user to use a mix of command line arguments and flags Enhance the import tool to detect missing packages in the modules side Added test cases for all commands
This commit is contained in:
27
utils/command.go
Normal file
27
utils/command.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"go/build"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Initialize the command based on the GO environment
|
||||
func CmdInit(c *exec.Cmd, basePath string) {
|
||||
c.Dir = basePath
|
||||
// Go 1.8 fails if we do not include the GOROOT
|
||||
c.Env = []string{"GOPATH=" + build.Default.GOPATH, "PATH=" + GetEnv("PATH"), "GOROOT="+ GetEnv("GOROOT")}
|
||||
|
||||
}
|
||||
|
||||
// Returns an environment variable
|
||||
func GetEnv(name string) string {
|
||||
for _, v := range os.Environ() {
|
||||
split := strings.Split(v, "=")
|
||||
if split[0] == name {
|
||||
return strings.Join(split[1:], "")
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
Reference in New Issue
Block a user