Search code examples
gomartini

return string as template


I would like to return a string as a template in martini in golang :

m.Get("/", func(r render.Render) string {
    template := "Hello world! <form name='input' action='../first' method='post' ><input type='texte' name='toto'><input type='submit' value='Submit'></form>"
    r.HTML(200, "post", template)

})

but it return me an error : missing return at end of function

Regards & thanks bussiere


Solution

  • You need to return the string so:

    m.Get("/", func(r render.Render) string {
        return "Hello world! <form name='input' action='../first' method='post' ><input type='texte' name='toto'><input type='submit' value='Submit'></form>"
    })