From de8bb0ed3665a50ba34093d71f85f8cca8229d73 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 6 Jun 2019 16:00:32 -0700 Subject: [PATCH] use shell.Chomp(). re-remove go.* files. can't figure them out still Signed-off-by: Jeff Carr --- config.go | 39 +++++---------------------------------- go.mod | 1 - go.sum | 1 - 3 files changed, 5 insertions(+), 36 deletions(-) delete mode 120000 go.mod delete mode 120000 go.sum diff --git a/config.go b/config.go index d536837..c8a5b01 100644 --- a/config.go +++ b/config.go @@ -20,7 +20,7 @@ import "runtime" import "io/ioutil" import "strings" import "reflect" -import "bytes" +// import "bytes" // import "sys" import "github.com/golang/protobuf/jsonpb" @@ -239,11 +239,9 @@ func parseConfig() { tagref = strings.TrimSpace(tagref) log.Println("VERSION git tag ref =", tagref) - currentRef := shell.Run("git rev-list -1 HEAD") - config.Gitref = chomp(currentRef) + config.Gitref = shell.Run("git rev-list -1 HEAD") - goversion := shell.Run("go version") - config.Goversion = chomp(goversion) + config.Goversion = shell.Run("go version") config.Dirty = false if (tagref == config.Gitref) { @@ -255,7 +253,7 @@ func parseConfig() { } buf, _ := wget("https://mirrors.wit.com/cloud/control-panel/VERSION") - upstream := chompBytesBuffer(buf) + upstream := shell.Chomp(buf) epoch := shell.Run("git log -1 --format=%at v" + version) // epoch = chomp(epoch) @@ -292,44 +290,17 @@ func parseConfig() { // spew.Dump(bi.Main) // log.Println("debug.BuildInfo.Path =", bi.Path) - errChan <- "hello" - errChan <- "hello" errChan <- "hello" errChan <- fmt.Errorf("blah") - errChan <- "hello" handleSignal(nil, 0) // my pid (cross platform) p, err := os.FindProcess(os.Getpid()) // send signal (cross platform) return p.Signal(syscall.SIGTERM) - // for {} + for {} // os.Exit(0) } -func chompBytesBuffer(buf *bytes.Buffer) string { - var bytesSplice []byte - bytesSplice = buf.Bytes() - - return chomp(string(bytesSplice)) -} - -// TODO: fix this to chomp \n \r NULL \t and ' ' -func chomp(s string) string { -// var bytesBuffer bytes.Buffer -// var bytesSplice []byte -// byteSlice := bytesBuffer.Bytes() -// b := bytes.Trim(byteSlice, "\x00") // removes NULL - s = strings.Trim(s, "\x00") - s = strings.Trim(s, "\n") - s = strings.Trim(s, "\n") - s = strings.TrimSuffix(s, "\r") - s = strings.TrimSuffix(s, "\n") - - s = strings.TrimSpace(s) // this is like 'chomp' in perl - s = strings.TrimSuffix(s, "\n") // this is like 'chomp' in perl - return s -} - func perl(a ...interface{}) { log.Println("reflect.TypeOf(a) =", reflect.TypeOf(a)) } diff --git a/go.mod b/go.mod deleted file mode 120000 index 32e656e..0000000 --- a/go.mod +++ /dev/null @@ -1 +0,0 @@ -resources/build/go.mod \ No newline at end of file diff --git a/go.sum b/go.sum deleted file mode 120000 index 82fe7ec..0000000 --- a/go.sum +++ /dev/null @@ -1 +0,0 @@ -resources/build/go.sum \ No newline at end of file