parent
74cdf39cbe
commit
294025f248
|
@ -10,6 +10,8 @@ example-aminal/example-aminal
|
||||||
example-multiple-windows/example-multiple-windows
|
example-multiple-windows/example-multiple-windows
|
||||||
example-lookupAAAA/example-lookupAAAA
|
example-lookupAAAA/example-lookupAAAA
|
||||||
|
|
||||||
|
build/build
|
||||||
|
|
||||||
test1/test1
|
test1/test1
|
||||||
test2/test2
|
test2/test2
|
||||||
test3/test3
|
test3/test3
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
all:
|
||||||
|
go build
|
||||||
|
./build
|
|
@ -0,0 +1,115 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import "log"
|
||||||
|
// import "fmt"
|
||||||
|
import "os"
|
||||||
|
import "os/user"
|
||||||
|
import "time"
|
||||||
|
import "runtime"
|
||||||
|
// import "io/ioutil"
|
||||||
|
// import "strings"
|
||||||
|
|
||||||
|
// github.com/bramvdbogaerde/go-scp
|
||||||
|
|
||||||
|
import "github.com/davecgh/go-spew/spew"
|
||||||
|
|
||||||
|
import "git.wit.com/wit/shell"
|
||||||
|
|
||||||
|
var filename string
|
||||||
|
var builddir string
|
||||||
|
var homedir string
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
os.Chdir("~/go/src/wit/cloud-control-panel")
|
||||||
|
|
||||||
|
setupUser()
|
||||||
|
|
||||||
|
log.Println("homedir", homedir)
|
||||||
|
log.Println("builddir", builddir)
|
||||||
|
log.Println("filename", filename)
|
||||||
|
|
||||||
|
shell.Run("pwd")
|
||||||
|
s, _ := os.Getwd()
|
||||||
|
log.Println("Getwd()", s)
|
||||||
|
os.Chdir(builddir)
|
||||||
|
log.Println("Getwd()", s)
|
||||||
|
shell.Run("pwd")
|
||||||
|
|
||||||
|
for {
|
||||||
|
time.Sleep(time.Second * 5)
|
||||||
|
build()
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
// slow down the polling to every 2 seconds
|
||||||
|
shell.SetDelayInMsec(2000)
|
||||||
|
shell.Run("ping -c 6 localhost")
|
||||||
|
|
||||||
|
// capture ping output into a file
|
||||||
|
fout, _ := os.Create("/tmp/example1.ping.stdout")
|
||||||
|
ferr, _ := os.Create("/tmp/example1.ping.stderr")
|
||||||
|
shell.SetStdout(fout)
|
||||||
|
shell.SetStderr(ferr)
|
||||||
|
|
||||||
|
shell.Run("ping -c 5 localhost")
|
||||||
|
|
||||||
|
// turn out process exit debugging
|
||||||
|
shell.SpewOn()
|
||||||
|
|
||||||
|
fout, _ = os.Create("/tmp/example1.fail.stdout")
|
||||||
|
ferr, _ = os.Create("/tmp/example1.fail.stderr")
|
||||||
|
shell.SetStdout(fout)
|
||||||
|
shell.SetStderr(ferr)
|
||||||
|
|
||||||
|
// TODO: this might not be working
|
||||||
|
// check error handling
|
||||||
|
shell.Run("ls /tmpthisisnothere")
|
||||||
|
*/
|
||||||
|
|
||||||
|
func build() {
|
||||||
|
// shell.SetDelayInMsec(50)
|
||||||
|
shell.Run("go get -v .")
|
||||||
|
|
||||||
|
shell.Run("rm " + filename)
|
||||||
|
shell.Run("go build")
|
||||||
|
output := shell.Run("ls -l")
|
||||||
|
shell.Run("cat VERSION")
|
||||||
|
|
||||||
|
log.Println("output =", output)
|
||||||
|
}
|
||||||
|
|
||||||
|
func ping() {
|
||||||
|
shell.SetDelayInMsec(2000)
|
||||||
|
shell.Run("ping -c 6 localhost")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// func setupUser() string, string, string {
|
||||||
|
func setupUser() {
|
||||||
|
// look up the user information
|
||||||
|
user, err := user.Current()
|
||||||
|
if err != nil {
|
||||||
|
os.Exit(-1)
|
||||||
|
}
|
||||||
|
spew.Dump(user)
|
||||||
|
|
||||||
|
// TODO: confirm this is correct for MacOS and Windows
|
||||||
|
if runtime.GOOS == "linux" {
|
||||||
|
log.Println("loadConfigFile() OS: Linux")
|
||||||
|
filename = "cloud-control-panel"
|
||||||
|
builddir = user.HomeDir + "/go/src/git.wit.com/wit/cloud-control-panel"
|
||||||
|
} else if runtime.GOOS == "windows" {
|
||||||
|
log.Println("loadConfigFile() OS: Windows")
|
||||||
|
builddir = user.HomeDir + "\\go\\src\\git.wit.com\\wit\\cloud-control-panel"
|
||||||
|
filename = "cloud-control-panel.exe"
|
||||||
|
} else {
|
||||||
|
log.Println("loadConfigFile() OS: " + runtime.GOOS)
|
||||||
|
builddir = user.HomeDir + "/go/src/git.wit.com/wit/cloud-control-panel"
|
||||||
|
filename = "cloud-control-panel"
|
||||||
|
}
|
||||||
|
|
||||||
|
homedir = user.HomeDir
|
||||||
|
}
|
Loading…
Reference in New Issue