main.go: go fmt - twitch-go - twitch.tv web application in Go
(HTM) git clone git://git.codemadness.org/twitch-go
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 46647bd75d4d84e1ae0ee82876dd7fed4fa2ec0d
(DIR) parent a8914a76f00467475d21935aea4f247613646a1e
(HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Sat, 11 Apr 2015 20:14:45 +0200
main.go: go fmt
Diffstat:
M main.go | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
---
(DIR) diff --git a/main.go b/main.go
@@ -135,7 +135,7 @@ type RouteMatch struct {
Names map[string]string
}
-type RouteHandler struct{
+type RouteHandler struct {
Routes []Route
}
@@ -384,10 +384,10 @@ func GameHandler(w http.ResponseWriter, r *http.Request, m *RouteMatch) error {
return err
}
v := struct {
- Name string
+ Name string
TwitchGame TwitchGame
- } {
- Name: m.Names["game"],
+ }{
+ Name: m.Names["game"],
TwitchGame: *game,
}
return RenderTemplate(w, "game.html", "page.html", v)
@@ -449,7 +449,7 @@ func main() {
appconfig.Addr = *arg_addr
appconfig.AddrType = *arg_addrtype
appconfig.Password = *arg_password
-
+
l, err := net.Listen(appconfig.AddrType, appconfig.Addr)
if err != nil {
panic(err)
@@ -470,7 +470,7 @@ func main() {
r := &RouteHandler{
Routes: routes,
}
-
+
// Write PID to pid file.
if appconfig.Pidfile != "" {
pid := os.Getpid()
@@ -478,7 +478,7 @@ func main() {
panic(err)
}
}
-
+
// Delete PID file on exit.
Cleaned := false
Cleanup := func() {
@@ -490,17 +490,17 @@ func main() {
os.Remove(appconfig.Pidfile)
}
}
-
+
// Setup cleanup handler.
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
- go func(){
- for sig := range c {
- if sig == syscall.SIGINT {
- Cleanup()
- os.Exit(1)
+ go func() {
+ for sig := range c {
+ if sig == syscall.SIGINT {
+ Cleanup()
+ os.Exit(1)
+ }
}
- }
}()
// Parse templates and keep in-memory.
@@ -514,7 +514,7 @@ func main() {
}
s := &http.Server{
- Handler: r,
+ Handler: r,
ReadTimeout: 10 * time.Second,
WriteTimeout: 10 * time.Second,
MaxHeaderBytes: 1 << 20,