Convert to templates

Signed-off-by: jolheiser <john.olheiser@gmail.com>
This commit is contained in:
jolheiser
2021-08-06 14:05:10 -05:00
parent ba26dc6adc
commit 782f70ba21
10 changed files with 21461 additions and 4677 deletions

View File

@ -15,7 +15,8 @@ import (
)
const (
protocolURL = "https://raw.githubusercontent.com/PrismarineJS/minecraft-data/master/data/pc/1.17.1/protocol.json"
protocolURL = "https://raw.githubusercontent.com/PrismarineJS/minecraft-data/master/data/pc/1.17.1/protocol.json"
//language=gohtml
packetidTmpl = `// This file is automatically generated by gen_packetIDs.go. DO NOT EDIT.
package packetid
@ -165,22 +166,20 @@ func downloadInfo() (*protocolIDs, error) {
//go:generate go run $GOFILE
//go:generate go fmt packetid.go
func main() {
fmt.Println("generating packetid.go")
pIDs, err := downloadInfo()
if err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
panic(err)
}
f, err := os.Create("packetid.go")
if err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
panic(err)
}
defer f.Close()
tmpl := template.Must(template.New("packetIDs").Parse(packetidTmpl))
if err := tmpl.Execute(f, pIDs); err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
panic(err)
}
}