Created
March 29, 2017 17:56
-
-
Save suminb/1417be6ebfc9f22ca20edf6d6281db91 to your computer and use it in GitHub Desktop.
Golang Practice
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- This file must be under `templates` directory --> | |
<h1>Hello World!</h1> | |
<div>{{.}}</div> | |
<div>{{ .key }}</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "github.com/go-martini/martini" | |
import "github.com/martini-contrib/render" | |
func main() { | |
m := martini.Classic() | |
m.Use(render.Renderer()) | |
m.Get("/", func() string { | |
return "Hello world!" | |
}) | |
m.Get("/test", func() (int, string) { | |
return 404, "NotFound" | |
}) | |
m.Get("/template", func(r render.Render) { | |
r.HTML(200, "index", map[string]interface{}{"key": "value"}) | |
}) | |
m.Run() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment