I’m struggling with calling a function where the arguments are a return from another function.
Working function
cmd := func(apiResp interface{}, err error) { ... }
I can call that function with
cmd(cli.ServerVersion(context.Background()))
where cli.ServerVersion()
== func (cli *Client) ServerVersion(ctx context.Context) (types.Version, error)
. 2 return types going to the cmd
function.
Adding a third argument to cmd
is where things break.
cmd := func(apiResp interface{}, err error, path string) { ... }
calling that with
cmd(cli.ServerVersion(context.Background()), "the/file/path")
causes the following errors:
-
multiple-value cli.ServerVersion() in single-value context```
-
not enough arguments in call to cmd
go version go1.11.4 darwin/amd64