fixed unnamed return values

This commit is contained in:
franklin 2016-12-13 17:03:56 +01:00
parent d244d82c85
commit 68dc67cac1
2 changed files with 8 additions and 9 deletions

View File

@ -22,7 +22,7 @@ func CallClient(url string, endpoint string, method string, args []interface{},
// Create request // Create request
request := "[" + strings.Join(jsonArgs, ",") + "]" request := "[" + strings.Join(jsonArgs, ",") + "]"
// Create post url // Create post url
postURL := fmt.Sprintf("%s%s%s", url, endpoint, method) postURL := fmt.Sprintf("%s%s/%s", url, endpoint, method)
// Post // Post
resp, err := http.Post(postURL, "application/json", strings.NewReader(request)) resp, err := http.Post(postURL, "application/json", strings.NewReader(request))
if err != nil { if err != nil {

15
go.go
View File

@ -3,8 +3,6 @@ package gotsrpc
import ( import (
"fmt" "fmt"
"strings" "strings"
"github.com/davecgh/go-spew/spew"
) )
func (v *Value) isHTTPResponseWriter() bool { func (v *Value) isHTTPResponseWriter() bool {
@ -164,9 +162,6 @@ func renderServiceProxies(services map[string]*Service, fullPackageName string,
imports += alias + " \"" + packageName + "\"\n" imports += alias + " \"" + packageName + "\"\n"
} }
spew.Dump(aliases)
spew.Dump(fullPackageName)
g.l(` g.l(`
// this file was auto generated by gotsrpc https://github.com/foomo/gotsrpc // this file was auto generated by gotsrpc https://github.com/foomo/gotsrpc
package ` + packageName + ` package ` + packageName + `
@ -342,9 +337,13 @@ func renderServiceProxies(services map[string]*Service, fullPackageName string,
} }
rets := []string{} rets := []string{}
returns := []string{} returns := []string{}
for _, r := range method.Return { for i, r := range method.Return {
rets = append(rets, "&"+r.Name) name := r.Name
returns = append(returns, r.Name+" "+r.Value.goType(aliases, fullPackageName)) if len(name) == 0 {
name = fmt.Sprintf("ret%s_%d", method.Name, i)
}
rets = append(rets, "&"+name)
returns = append(returns, name+" "+r.Value.goType(aliases, fullPackageName))
} }
returns = append(returns, "err error") returns = append(returns, "err error")
g.l(`func (c *` + clientName + `) ` + method.Name + `(` + strings.Join(params, ", ") + `) (` + strings.Join(returns, ", ") + `) {`) g.l(`func (c *` + clientName + `) ` + method.Name + `(` + strings.Join(params, ", ") + `) (` + strings.Join(returns, ", ") + `) {`)