Ver Fonte

json处理

tanglin há 9 meses atrás
pai
commit
78e436f10e
1 ficheiros alterados com 6 adições e 1 exclusões
  1. 6 1
      cmd/go-pre-version/main.go

+ 6 - 1
cmd/go-pre-version/main.go

@@ -82,8 +82,13 @@ func main() {
 			fmt.Println("open ", winVersionFile, "error: ", err)
 			os.Exit(1)
 		}
+		buffer := new(bytes.Buffer)
+		if err := json.Compact(buffer, winB); err != nil {
+			fmt.Println("json.Compact error: ", err)
+			os.Exit(1)
+		}
 		var winV windowsVersion
-		err = json.Unmarshal(winB, &winV)
+		err = json.Unmarshal(buffer.Bytes(), &winV)
 		if err != nil {
 			fmt.Println("invalid format of Windows version info: ", err, string(winB))
 			os.Exit(1)