草庐IT

method-group

全部标签

Golang (v1.8) - 错误 : type *mux. Route has no field or method Method

我有一个配备了gorilla工具包的go/golang应用程序。我正在尝试使用gorilla/mux包进行路由。我的路线和错误信息如下。有什么指点吗?路线`r:=mux.NewRouter()r.HandleFunc("/",landing)r.HandleFunc("/contact",contact)r.HandleFunc("/faq",faq)r.HandleFunc("/register",accountsC.New).Method("GET")r.HandleFunc("/register",accountsC.Create).Method("POST")http.List

azure - 去 + azure : Calling a method return undefined

我正在尝试使用GoAzureSDK调用通知中心api我已经安装了SDK并导入到GO文件中:packagehubimport("fmt""github.com/Azure/azure-sdk-for-go/arm/notificationhubs")funcGetHub(){ifresourceType,err:=notificationhubs.Get("sourceGroupName","NameSpaceValue","NameOfTheHub");err!=nil{fmt.Println("Erroroccured")return}fmt.Println("Success")}然

go - Group 没有实现 Data(FooMethod 方法有指针接收器)

这是我的代码:packagemainimport"fmt"typeGroupstruct{}func(g*Group)FooMethod()string{return"foo"}typeDatainterface{FooMethod()string}funcNewJsonResponse(dData)Data{returnd}funcmain(){vargGroupjson:=NewJsonResponse(g)fmt.Println("vim-go")}但没有像我预期的那样工作。$gobuildmain.go#command-line-arguments./main.go:22:ca

google-app-engine - 谷歌应用引擎/啊/健康 "Method does not exist."

对projectname.appspot.com/_ah/health的请求返回以下错误{"code":5,"message":"Methoddoesnotexist.","details":[{"@type":"type.googleapis.com/google.rpc.DebugInfo","stackEntries":[],"detail":"service_control"}]}本地测试,效果很好。缩写的app.yaml:runtime:goenv:flexapi_version:go1app.go主要功能:funcmain(){r:=mux.NewRouter()r.Han

methods - Go:方法调用后对象不持久

我正在尝试为我正在编写的程序实现MarshalBinary和UnmarshalBinary,但在调用UnmarshalBinary后,我的更改似乎并没有持续存在。我的MWE:packagemainimport("encoding/binary""fmt""strconv")typeteststruct{var1uint32var2uint32}func(selftest)MarshalBinary()([]byte,error){tmp:=make([]byte,8)binary.BigEndian.PutUint32(tmp[0:4],self.var1)binary.BigEndi

go - 文本/模板 : "can' t call method/function with 0 results. "

如何在不返回任何值的模板中执行函数?这是示例:funcmain(){u,err:=url.Parse("http://example.com/test?param1=true¶m2=true")iferr!=nil{log.Fatal(err)}m:=u.Query()m.Del("param1")//param1successfuldeleted!u.RawQuery=m.Encode()fmt.Println(u.RawQuery)consttmpl=`{{$m:=.Query}}{{$m.Del"param2"}}{{.RawQuery}}`t:=template.Mus

function - 戈朗 : Stack multiple method calls on one line

Go入门。我正在尝试编写一个函数,该函数将第一个名字命名为首字母,然后将第二个命名为首字母。为什么我不能像下面这样堆叠方法调用?(之所以要在前面放一个.ToLower,是因为.Title只把第一个字母大写,其余的不变)packagemainimport("fmt""strings")funcmain(){firstName:="mElVIn"lastName:="themelvINATor"fmt.Println(nameCap(firstName,lastName))}funcnameCap(s1,s2string)(str1,str2string){s1=strings.ToLow

去建立错误 "db.GetUsers undefined (type *gorm.DB has no field or method GetUsers)"

我是golang的新手,正在尝试使用gin+gorm制作API服务器。我尝试构建下面的代码,但出现了type*gorm.DBhasnofieldormethodGetUsers错误。这是一个非常简单的API服务器,我只想从users表中获取所有用户。packagemodelsimport("github.com/jinzhu/gorm"_"github.com/jinzhu/gorm/dialects/postgres")vardb*gorm.DBfuncinit(){varerrerrordb,err=gorm.Open("postgres","host=localhostdbnam

go - 嵌套接口(interface) : X does not implement Y (Wrong type for Z method)

在一个包中我有一个接口(interface)Repository有一个方法GetReporter返回一个接口(interface)Reporter.这是由一个函数使用Execute这需要Repository并得到它的Reporter通过GetReporter功能。在另一个包中我有一个结构GithubRepository有一个方法GetReporter返回GithubReporter.在第三个包中,我想调用Execute使用GithubRepository在包#1外运行实例。我正在尝试让包1和包2彼此独立,而不是从另一个导入某些东西。第三个包应该结合前两个。Golang返回:cannot

c# - 错误 : A query body must end with a select clause or a group clause

我有这样一个xml:nota1nota2nota3nota4nota1nota2nota3nota4如何使用LINQtoXML获取特定类型的列表?我试过这样的事情:我创建了一个类:publicclassIdeas{publicstringCountry{get;set;}publicListListIdeas{get;set;}}然后我用这个类做一个列表:XDocumentxdoc=XDocument.Load(this.Server.MapPath("~/config/ideas.xml"));varcat=frompinxdoc.Descendants("countries").E