From 0da0a33d499544dbe526e37cbaf1525bae8ef2ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C7=8Eili=C3=A0ng=20W=C3=A1ng?= Date: Fri, 11 Sep 2015 16:03:02 +0800 Subject: [PATCH] follow convension. --- proto/pre.go | 9 ++++++++- proto/type.go | 6 +++--- spec/gen/gen.go | 2 ++ spec/gen/main.go | 2 +- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/proto/pre.go b/proto/pre.go index f5fe9f7..9e614cf 100644 --- a/proto/pre.go +++ b/proto/pre.go @@ -1,3 +1,10 @@ package proto -type T interface{} +import ( + "encoding" +) + +type T interface { + encoding.BinaryMarshaler + encoding.BinaryUnmarshaler +} diff --git a/proto/type.go b/proto/type.go index cf9d549..480752c 100644 --- a/proto/type.go +++ b/proto/type.go @@ -6,8 +6,8 @@ type RequestOrResponse struct { } type Request struct { - ApiKey int16 - ApiVersion int16 + APIKey int16 + APIVersion int16 CorrelationID int32 ClientID string RequestMessage RequestMessage @@ -62,7 +62,7 @@ type PartitionMetadata struct { PartitionID int32 Leader int32 Replicas int32 - Isr int32 + ISR int32 } type ProduceRequest struct { diff --git a/spec/gen/gen.go b/spec/gen/gen.go index 14f3806..1bc54e5 100644 --- a/spec/gen/gen.go +++ b/spec/gen/gen.go @@ -97,6 +97,8 @@ func goName(s string) string { return strings.TrimSuffix(s, "Id") + "ID" } s = strings.Replace(s, "Crc", "CRC", -1) + s = strings.Replace(s, "Api", "API", -1) + s = strings.Replace(s, "Isr", "ISR", -1) return s } diff --git a/spec/gen/main.go b/spec/gen/main.go index 755f26d..a7f7d3e 100644 --- a/spec/gen/main.go +++ b/spec/gen/main.go @@ -7,7 +7,7 @@ import ( func main() { if len(os.Args) != 2 { - fmt.Println("go run gen.go (bnf | json | go)") + fmt.Println("gen (bnf | json | go)") return } switch os.Args[1] {