internal/cmd/convertshaders: use gofmt to format output

In particular, the simplifying "-s" flag to gofmt ensures that the automatic
test for unformatted Go source files won't complain.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2020-02-27 21:39:12 +01:00
parent 591c89ab0a
commit d65bfdc275
3 changed files with 31 additions and 30 deletions
+6 -5
View File
@@ -7,7 +7,6 @@ import (
"encoding/json"
"flag"
"fmt"
"go/format"
"io/ioutil"
"os"
"os/exec"
@@ -178,11 +177,13 @@ func generate() error {
}
}
out.WriteString(")")
gosrc, err := format.Source(out.Bytes())
if err != nil {
return fmt.Errorf("shader.go: %v", err)
if err := ioutil.WriteFile("shaders.go", out.Bytes(), 0644); err != nil {
return err
}
return ioutil.WriteFile("shaders.go", gosrc, 0644)
cmd := exec.Command("gofmt", "-s", "-w", "shaders.go")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd.Run()
}
func parseReflection(jsonData []byte, info *backend.ShaderSources) error {