Explorar el Código

fixed GoVersion and some formatting issues

Staffan Olsson hace 3 años
padre
commit
0046139739
Se han modificado 3 ficheros con 16 adiciones y 9 borrados
  1. 2 2
      client.go
  2. 13 5
      environ.go
  3. 1 2
      server.go

+ 2 - 2
client.go

@@ -38,10 +38,10 @@ func GetBuildInfo(conn *grpc.ClientConn, timeout time.Duration) (clientEnv *Envi
 func PrintBuildInfo(out io.Writer, clientEnv, serverEnv *Environment) {
 	if clientEnv != nil {
 		w := tabwriter.NewWriter(out, 0, 0, 1, ' ', 0)
-		fmt.Fprintf(w, "Client:")
+		fmt.Fprintln(w, "Client:")
 		fmt.Fprintf(w, " Version:\t%s\n", clientEnv.Version)
 		fmt.Fprintf(w, " API version:\t%s\n", clientEnv.ApiVersion)
-		fmt.Fprintf(w, " Go version:\t%s\n", clientEnv.Version)
+		fmt.Fprintf(w, " Go version:\t%s\n", clientEnv.GoVersion)
 		fmt.Fprintf(w, " Git commit:\t%s\n", clientEnv.GitCommit)
 		fmt.Fprintf(w, " Built:\t%s\n", clientEnv.BuildTime)
 		fmt.Fprintf(w, " OS/Arch:\t%s\n", clientEnv.GoOsArch)

+ 13 - 5
environ.go

@@ -4,6 +4,8 @@
 
 package environ
 
+import "runtime"
+
 var (
 	// The following variables are set at build time by scripts/build.sh
 
@@ -21,22 +23,28 @@ var (
 
 	// APIVersion is from api/version.txt
 	APIVersion string
+
+	// GoVersion is the current version of the go compiler
+	GoVersion string
 )
 
 func init() {
 	if GitCommit == "" {
-		GitCommit = "<debug>"
+		GitCommit = "<not set>"
 	}
 	if BuildTime == "" {
-		BuildTime = "<debug>"
+		BuildTime = "<not set>"
 	}
 	if GoOsArch == "" {
-		GoOsArch = "<debug>"
+		GoOsArch = "<not set>"
 	}
 	if Version == "" {
-		Version = "<debug>"
+		Version = "<not set>"
 	}
 	if APIVersion == "" {
-		APIVersion = "<debug>"
+		APIVersion = "<not set>"
+	}
+	if GoVersion == "" {
+		GoVersion = runtime.Version()
 	}
 }

+ 1 - 2
server.go

@@ -2,7 +2,6 @@ package environ
 
 import (
 	context "context"
-	"runtime"
 
 	grpc "google.golang.org/grpc"
 )
@@ -20,7 +19,7 @@ func (s *Server) GetEnvironment(context.Context, *Void) (*Environment, error) {
 		BuildTime:  BuildTime,
 		GoOsArch:   GoOsArch,
 		ApiVersion: Version,
-		GoVersion:  runtime.Version(),
+		GoVersion:  GoVersion,
 	}
 	return rsp, nil
 }