Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions generator/go.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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)
}
4 changes: 2 additions & 2 deletions thrift/protocol_compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}

Expand Down