Skip to content

Commit

Permalink
Regenerate view_gen.go file with gofmt
Browse files Browse the repository at this point in the history
  • Loading branch information
unitoftime committed Oct 14, 2024
1 parent 8afcb57 commit 498092e
Show file tree
Hide file tree
Showing 3 changed files with 6,509 additions and 5 deletions.
4 changes: 2 additions & 2 deletions component.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ type componentRegistry struct {

func newComponentRegistry() *componentRegistry {
r := &componentRegistry{
archSet: make([][]archetypeId, maxComponentId+1), // TODO: hardcoded to max component
archMask: make(map[archetypeMask]archetypeId),
archSet: make([][]archetypeId, maxComponentId+1), // TODO: hardcoded to max component
archMask: make(map[archetypeMask]archetypeId),
revArchMask: make([]archetypeMask, 0),
}
return r
Expand Down
22 changes: 19 additions & 3 deletions internal/gen/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package main

import (
"bytes"
_ "embed"
"go/format"
"io/fs"
"os"
"strings"
"text/template"
Expand Down Expand Up @@ -83,11 +86,24 @@ func main() {

t := template.Must(template.New("ViewTemplate").Funcs(funcs).Parse(viewTemplate))

viewFile, err := os.OpenFile("view_gen.go", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0755)
buf := bytes.NewBuffer([]byte{})

t.Execute(buf, data)

filename := "view_gen.go"

// Attempt to write the file as formatted, falling back to writing it normally
formatted, err := format.Source(buf.Bytes())
if err != nil {
err = os.WriteFile(filename, buf.Bytes(), fs.ModePerm)
if err != nil {
panic(err)
}
panic(err)
}
defer viewFile.Close()

t.Execute(viewFile, data)
err = os.WriteFile(filename, formatted, fs.ModePerm)
if err != nil {
panic(err)
}
}
Loading

0 comments on commit 498092e

Please sign in to comment.