草庐IT

AssetHandler

全部标签

go - 将对象传递给其他包中的结构

我有一个主函数,我在其中启动一个变量,一个客户端。例如:funcmain(){myClient:=my.MustNewClient("localhost")}现在我想将此客户端传递给另一个包,但出于某种原因我不知道如何执行此操作。我的包裹看起来像这样:packagerestimport("net/http""github.com/Sirupsen/logrus")typeAssetHandlerstruct{mcmy.Client}func(fAssetHandler)ServeHTTP(whttp.ResponseWriter,r*http.Request){logrus.Info(

go - 将对象传递给其他包中的结构

我有一个主函数,我在其中启动一个变量,一个客户端。例如:funcmain(){myClient:=my.MustNewClient("localhost")}现在我想将此客户端传递给另一个包,但出于某种原因我不知道如何执行此操作。我的包裹看起来像这样:packagerestimport("net/http""github.com/Sirupsen/logrus")typeAssetHandlerstruct{mcmy.Client}func(fAssetHandler)ServeHTTP(whttp.ResponseWriter,r*http.Request){logrus.Info(