第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Golang 重置服務(wù) post 方法 post 數(shù)據(jù)未定義

Golang 重置服務(wù) post 方法 post 數(shù)據(jù)未定義

Go
白衣非少年 2021-09-27 16:04:44
我正在使用 google golang reset 服務(wù),當(dāng)我嘗試運行此代碼時,post 方法出現(xiàn)問題,它顯示 post 數(shù)據(jù)未定義    package mainimport (    "code.google.com/p/gorest"    "fmt"    "net/http")type Invitation struct {    User string}//Service Definitiontype HelloService struct {    gorest.RestService    //gorest.RestService `root:"/tutorial/"`    helloWorld gorest.EndPoint `method:"GET" path:"/hello-world/" output:"string"`    sayHello   gorest.EndPoint `method:"GET" path:"/hello/{name:string}" output:"string"`    posted     gorest.EndPoint `method:"POST" path:"/post/"  postdata:"User" `}func main() {    gorest.RegisterService(new(HelloService)) //Register our service    http.Handle("/", gorest.Handle())    http.ListenAndServe(":8787", nil)}func (serv HelloService) Posted(posted User) {    fmt.Println(User)}func (serv HelloService) HelloWorld() string {    return "Hello World"}func (serv HelloService) SayHello(name string) string {    return "Hello " + name}這是我得到的錯誤# command-line-arguments./registation.go:28: undefined: User./registation.go:29: undefined: User請幫忙解決這個問題
查看完整描述

2 回答

?
ibeautiful

TA貢獻1993條經(jīng)驗 獲得超6個贊

func (serv HelloService) Posted(posted User) {

    fmt.Println(User)

}

應(yīng)該


func (serv HelloService) Posted(posted User) {

    fmt.Println(posted)

}

Posted 方法接受一個名為posted 和User 類型的參數(shù)。


你應(yīng)該打印實際的參數(shù),而不是它的類型 - 就像你在這里


func (serv HelloService) SayHello(name string) string {

    return "Hello " + name

}



查看完整回答
反對 回復(fù) 2021-09-27
  • 2 回答
  • 0 關(guān)注
  • 205 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號