From d546840d6fe7fa185915e3bc8e37fc8d948304da Mon Sep 17 00:00:00 2001 From: Wuvist Date: Mon, 4 Apr 2016 17:54:28 +0800 Subject: [PATCH 1/3] Fix return type typo for oneway method --- generator/go.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generator/go.go b/generator/go.go index 9d6463b..af7432a 100644 --- a/generator/go.go +++ b/generator/go.go @@ -565,7 +565,7 @@ func (g *GoGenerator) writeService(out io.Writer, svc *parser.Service) error { for _, k := range methodNames { method := svc.Methods[k] methodName := camelCase(method.Name) - returnType := "err error" + returnType := "(err error)" if !method.Oneway { returnType = g.formatReturnType(method.ReturnType, true) } From c78c7ca1c793539b0583625936736bc349574376 Mon Sep 17 00:00:00 2001 From: dtynn Date: Mon, 25 Apr 2016 19:03:44 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=8C=89=E7=85=A7=20thrift=20=E5=AE=98?= =?UTF-8?q?=E6=96=B9=E5=AE=9E=E7=8E=B0,=20=E4=BD=BF=E7=94=A8=20LittleEndia?= =?UTF-8?q?n=20=E5=AF=B9=20double=20=E8=BF=9B=E8=A1=8C=E5=BA=8F=E5=88=97?= =?UTF-8?q?=E5=8C=96=E5=8F=8D=E5=BA=8F=E5=88=97=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- thrift/protocol_compact.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/thrift/protocol_compact.go b/thrift/protocol_compact.go index 3a9afcb..fdeff0c 100644 --- a/thrift/protocol_compact.go +++ b/thrift/protocol_compact.go @@ -267,7 +267,7 @@ func (p *compactProtocolWriter) WriteI64(value int64) error { func (p *compactProtocolWriter) WriteDouble(value float64) (err error) { b := p.buf - binary.BigEndian.PutUint64(b, math.Float64bits(value)) + binary.LittleEndian.PutUint64(b, math.Float64bits(value)) _, err = p.w.Write(b[:8]) return } @@ -540,7 +540,7 @@ func (p *compactProtocolReader) ReadI64() (int64, error) { func (p *compactProtocolReader) ReadDouble() (float64, error) { b := p.buf _, err := io.ReadFull(p.r, b[:8]) - value := math.Float64frombits(binary.BigEndian.Uint64(b)) + value := math.Float64frombits(binary.LittleEndian.Uint64(b)) return value, err } From 8732e13fb0a9f8d1cf2d72d7d5f8c55baeb9a882 Mon Sep 17 00:00:00 2001 From: dtynn Date: Mon, 9 May 2016 13:56:51 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E5=90=AB=E6=9C=89'.'?= =?UTF-8?q?=E7=9A=84=E6=96=87=E4=BB=B6=E7=9B=AE=E5=BD=95=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- generator/go.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/generator/go.go b/generator/go.go index af7432a..8df3a9b 100644 --- a/generator/go.go +++ b/generator/go.go @@ -732,18 +732,14 @@ func (g *GoGenerator) Generate(outPath string) (err error) { for _, k := range goNamespaceOrder { pkg.Name = th.Namespaces[k] if pkg.Name != "" { - parts := strings.Split(pkg.Name, ".") - if len(parts) > 1 { - pkg.Path = strings.Join(parts[:len(parts)-1], "/") - pkg.Name = parts[len(parts)-1] - } + pkg.Path, pkg.Name = genNamespace(pkg.Name) break } } if pkg.Name == "" { pkg.Name = filepath.Base(path) } - pkg.Name = validIdentifier(strings.ToLower(pkg.Name), "_") + pkg.Name = validIdentifier(pkg.Name, "_") g.Packages[path] = pkg } } @@ -813,3 +809,14 @@ func (g *GoGenerator) Generate(outPath string) (err error) { return nil } + +func genNamespace(namespace string) (string, string) { + var path string + if strings.Contains(namespace, "..") { + path = strings.Replace(namespace, "..", "/", -1) + } else { + path = strings.Replace(namespace, ".", "/", -1) + } + + return filepath.Dir(path), filepath.Base(path) +}