diff --git a/generator/go.go b/generator/go.go index 9d6463b..8df3a9b 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) } @@ -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) +} 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 }