How to return only one variable in multi return function in GO? -
hi have function want return docker.apicontainer , error (nil if no errors), in case of error should return in docker.apicontainer ?
this code
func getcontainersrunningimage(imagename string, tag string) ([]docker.container,string) { logfields := log.fields{ "handler": "get service", } client, err := docker.newtlsclient(sconf.dockconf.endpoint, sconf.dockconf.cert, sconf.dockconf.key, sconf.dockconf.ca) if err != nil { log.withfields(logfields).errorf("tlsclient not created: %s", err) return _,err.error() } }
what should add instead of _? obliged create var contarray []docker.container
, return it? or there way
return nil, err.error()
goreturns automatically - 0
int , ""
string etc.
Comments
Post a Comment