go - Golang reset service post method post data undefined -


hi working google golang reset service have issue post method when try run code show post data undefined

    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 } 

this error getting

# command-line-arguments ./registation.go:28: undefined: user ./registation.go:29: undefined: user 

please fix issue
thank

func (serv helloservice) posted(posted user) {     fmt.println(user) } 

should

func (serv helloservice) posted(posted user) {     fmt.println(posted) } 

the posted method takes parameter name of posted , type of user.

you should printing actual paramater, not it's type - have here

func (serv helloservice) sayhello(name string) string {     return "hello " + name } 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -