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

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -