-1
你好我與谷歌golang重置服務工作我有POST方法 問題,當我嘗試運行這段代碼是展後數據不確定Golang重置服務post方法後的數據不確定
package main
import (
"code.google.com/p/gorest"
"fmt"
"net/http"
)
type Invitation struct {
User string
}
//Service Definition
type 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
請幫忙解決這個問題
謝謝
IMO的錯誤信息是非常* *清晰。在第28行你有'...(發佈用戶)',它試圖使用'用戶'作爲一種類型。您尚未定義任何此類型。在第29行,你有'fmt.Println(用戶)'這是試圖使用'用戶'作爲一個變量。你還沒有定義任何這樣的變量。也許你需要(重新)學習[語言規範](https://golang.org/reg/spec)或(重新)參加[Go tour](http://tour.golang.org/)或使用您可以在[Go tag wiki](http://stackoverflow.com/tags/go/info)上找到其他一些基本參考資料。 – 2015-04-01 05:28:32
是的,我知道 我使用本教程https://code.google.com/p/gorest/ 你能告訴我方式來訪問這篇文章數據 – smartechno 2015-04-01 06:00:02