I'm trying to print a user's username that the user keyed into a form, using Fprintf:
GO code:
const logPage = `
<html>
<form action="/login" method="POST">
<label for="name">Username</label>
<input type="text" id="Username" name="name"></input>
...
</form>
</html>
`
const homePage = `
<html>
<h1>hi %s</h1>
</html>
`
func homehandler(w http.ResponseWriter, r *http.Request) {
a = r.FormValue("name")
fmt.Fprintf(w, homePage, a) ---> how do I insert the a value in the required interface{} form?
}
func main() {
http.HandleFunc("/home", homehandler)
...
}
According to this: http://golang.org/pkg/net/http/#Request.FormValue, FormValue returns a string, but Fprintf seems to require an interface type: http://golang.org/pkg/fmt/#Fprintf. How do I insert the correct value/type of "a" as in my code above? Or, is there a better way to do this?