fix go scalar args conversion

This commit is contained in:
franklin 2016-12-13 17:45:11 +01:00
parent 68dc67cac1
commit 3be8701fd9
2 changed files with 7 additions and 6 deletions

View File

@ -11,7 +11,7 @@ import (
// CallClient calls a method on the remove service
func CallClient(url string, endpoint string, method string, args []interface{}, reply []interface{}) error {
// Marshall args
jsonArgs := make([]string, len(args))
jsonArgs := []string{}
for _, value := range args {
jsonArg, err := json.Marshal(value)
if err != nil {
@ -29,15 +29,15 @@ func CallClient(url string, endpoint string, method string, args []interface{},
return err
}
defer resp.Body.Close()
// Check status
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("Error: %s", resp.Status)
}
// Read in body
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return err
}
// Check status
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("%s: %s", resp.Status, string(body))
}
// Unmarshal reply
if err := json.Unmarshal(body, &reply); err != nil {
return err

3
go.go
View File

@ -259,7 +259,8 @@ func renderServiceProxies(services map[string]*Service, fullPackageName string,
args = append(args, arg.Value.emptyLiteral(aliases))
switch arg.Value.GoScalarType {
case "int64":
case "int", "int8", "int16", "int32", "int64",
"uint", "uint8", "uint16", "uint32", "uint64":
callArgs = append(callArgs, fmt.Sprint(arg.Value.GoScalarType+"(args[", skipArgI, "].(float64))"))
default:
// assert