cmd/generator: format output source

This commit is contained in:
Koichi Shiraishi 2020-11-13 00:25:57 +09:00
parent 09fe33f8f0
commit 740b951cb5
No known key found for this signature in database
GPG Key ID: A71DFD3B4DA7A79B
1 changed files with 6 additions and 1 deletions

View File

@ -3,6 +3,7 @@ package main
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"go/format"
"io/ioutil" "io/ioutil"
"path/filepath" "path/filepath"
"runtime" "runtime"
@ -380,7 +381,11 @@ func (t opType) fieldToStringTagField() opType {
return err return err
} }
path := filepath.Join(repoRoot(), "encode_optype.go") path := filepath.Join(repoRoot(), "encode_optype.go")
return ioutil.WriteFile(path, b.Bytes(), 0644) buf, err := format.Source(b.Bytes())
if err != nil {
return err
}
return ioutil.WriteFile(path, buf, 0644)
} }
func repoRoot() string { func repoRoot() string {