me when i dont use vcs properly

This commit is contained in:
adman
2025-12-30 14:15:43 +01:00
parent 0b493d43f3
commit 8400d8f5dc
15 changed files with 192 additions and 94 deletions
+4 -5
View File
@@ -79,14 +79,13 @@ func CollectPacketInfo(versions []string) (packetInfos []PacketInfo, err error)
}
func GeneratePacketInfoFile(versions []string) (err error) {
var packetInfos []PacketInfo
packetInfos, err = CollectPacketInfo(versions)
packetInfos, err := CollectPacketInfo(versions)
if err != nil {
return
}
f := NewFile("proto_generated")
imports := []string{"reflect", "github.com/admin-else/strom/proto_base"}
imports := []string{"github.com/admin-else/strom/proto_base"}
for _, v := range versions {
vUnderscore := strings.ReplaceAll(v, ".", "_")
imports = append(imports, "github.com/admin-else/strom/proto_generated/v"+vUnderscore)
@@ -109,8 +108,8 @@ func GeneratePacketInfoFile(versions []string) (err error) {
packetId, _ := strconv.ParseInt(p.PacketId, 0, 32)
protocolVersion, _ := strconv.Atoi(p.ProtocolVersion)
packetInfoExprs = append(packetInfoExprs, CompLit(Selector("proto_base", "PacketInfo"), []ast.Expr{
KeyValueExpr(Ident("Type"), Call(Selector("reflect", "TypeOf"), CompLit(typeExpr, nil))),
packetInfoExprs = append(packetInfoExprs, CompLit(nil, []ast.Expr{
KeyValueExpr(Ident("Type"), AddrOf(CompLit(typeExpr, nil))),
KeyValueExpr(Ident("Name"), StrLit(p.Name)),
KeyValueExpr(Ident("Direction"), Selector("proto_base", p.Direction)),
KeyValueExpr(Ident("State"), Selector("proto_base", p.State)),