mirror of
https://tangled.org/evan.jarrett.net/at-container-registry
synced 2026-08-31 13:17:09 +00:00
34 lines
746 B
Go
34 lines
746 B
Go
package main
|
|
|
|
// CBOR Code Generator
|
|
//
|
|
// This generates optimized CBOR marshaling code for ATProto records.
|
|
//
|
|
// Usage:
|
|
// go run gen/main.go
|
|
//
|
|
// This creates pkg/atproto/cbor_gen.go which should be committed to git.
|
|
// Only re-run when you modify types in pkg/atproto/types.go
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
cbg "github.com/whyrusleeping/cbor-gen"
|
|
|
|
"atcr.io/pkg/atproto"
|
|
)
|
|
|
|
func main() {
|
|
// Generate map-style encoders for CrewRecord and CaptainRecord
|
|
if err := cbg.WriteMapEncodersToFile("pkg/atproto/cbor_gen.go", "atproto",
|
|
atproto.CrewRecord{},
|
|
atproto.CaptainRecord{},
|
|
); err != nil {
|
|
fmt.Printf("Failed to generate CBOR encoders: %v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
fmt.Println("Generated CBOR encoders in pkg/atproto/cbor_gen.go")
|
|
}
|