use shell.Chomp(). re-remove go.* files. can't figure them out still
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
5b33e2cf09
commit
de8bb0ed36
39
config.go
39
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))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue