Convert to templates
Signed-off-by: jolheiser <john.olheiser@gmail.com>
This commit is contained in:
@ -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)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user