From baf468973f5aa52493b4eefadf64d2e89b661860 Mon Sep 17 00:00:00 2001 From: Benjamin Manns Date: Thu, 6 Mar 2014 10:45:21 -0800 Subject: [PATCH 1/2] Format go code. --- pkg/build/build.go | 2 +- pkg/handler/repos.go | 4 +-- pkg/plugin/notify/irc.go | 54 +++++++++++++++---------------- pkg/plugin/notify/notification.go | 10 +++--- pkg/plugin/publish/pypi.go | 1 - pkg/template/template.go | 4 +-- 6 files changed, 37 insertions(+), 38 deletions(-) diff --git a/pkg/build/build.go b/pkg/build/build.go index 3fd08fb8..337e5021 100644 --- a/pkg/build/build.go +++ b/pkg/build/build.go @@ -514,7 +514,7 @@ func (b *Builder) writeProxyScript(dir string) error { // map ip address to localhost for _, container := range b.services { // create an entry for each port - for port, _ := range container.NetworkSettings.Ports { + for port := range container.NetworkSettings.Ports { proxyfile.Set(port.Port(), container.NetworkSettings.IPAddress) } } diff --git a/pkg/handler/repos.go b/pkg/handler/repos.go index 8d728814..c49116b1 100644 --- a/pkg/handler/repos.go +++ b/pkg/handler/repos.go @@ -60,8 +60,8 @@ func RepoAdd(w http.ResponseWriter, r *http.Request, u *User) error { return err } data := struct { - User *User - Teams []*Team + User *User + Teams []*Team Settings *Settings }{u, teams, settings} // if the user hasn't linked their GitHub account diff --git a/pkg/plugin/notify/irc.go b/pkg/plugin/notify/irc.go index 93127e07..0a1cc481 100644 --- a/pkg/plugin/notify/irc.go +++ b/pkg/plugin/notify/irc.go @@ -1,9 +1,9 @@ package notify import ( - "fmt" + "fmt" - irc "github.com/fluffle/goirc/client" + irc "github.com/fluffle/goirc/client" ) const ( @@ -13,29 +13,30 @@ const ( ) type IRC struct { - Channel string `yaml:"channel,omitempty"` - Nick string `yaml:"nick,omitempty"` - Server string `yaml:"server,omitempty"` - Started bool `yaml:"on_started,omitempty"` - Success bool `yaml:"on_success,omitempty"` - Failure bool `yaml:"on_failure,omitempty"` - SSL bool `yaml:"ssl,omitempty"` + Channel string `yaml:"channel,omitempty"` + Nick string `yaml:"nick,omitempty"` + Server string `yaml:"server,omitempty"` + Started bool `yaml:"on_started,omitempty"` + Success bool `yaml:"on_success,omitempty"` + Failure bool `yaml:"on_failure,omitempty"` + SSL bool `yaml:"ssl,omitempty"` ClientStarted bool - Client *irc.Conn + Client *irc.Conn } func (i *IRC) Connect() { - c := irc.SimpleClient(i.Nick) - c.SSL = i.SSL - connected := make(chan bool) - c.AddHandler(irc.CONNECTED, - func(conn *irc.Conn, line *irc.Line) { - conn.Join(i.Channel) - connected <- true}) - c.Connect(i.Server) - <-connected - i.ClientStarted = true - i.Client = c + c := irc.SimpleClient(i.Nick) + c.SSL = i.SSL + connected := make(chan bool) + c.AddHandler(irc.CONNECTED, + func(conn *irc.Conn, line *irc.Line) { + conn.Join(i.Channel) + connected <- true + }) + c.Connect(i.Server) + <-connected + i.ClientStarted = true + i.Client = c } func (i *IRC) Send(context *Context) error { @@ -53,7 +54,7 @@ func (i *IRC) Send(context *Context) error { func (i *IRC) sendStarted(context *Context) error { msg := fmt.Sprintf(ircStartedMessage, context.Repo.Name, context.Commit.HashShort(), context.Commit.Author) i.send(i.Channel, msg) - return nil + return nil } func (i *IRC) sendFailure(context *Context) error { @@ -62,23 +63,22 @@ func (i *IRC) sendFailure(context *Context) error { if i.ClientStarted { i.Client.Quit() } - return nil + return nil } func (i *IRC) sendSuccess(context *Context) error { msg := fmt.Sprintf(ircSuccessMessage, context.Repo.Name, context.Commit.HashShort(), context.Commit.Author) i.send(i.Channel, msg) if i.ClientStarted { - i.Client.Quit() + i.Client.Quit() } - return nil + return nil } - func (i *IRC) send(channel string, message string) error { if !i.ClientStarted { i.Connect() } i.Client.Notice(channel, message) - return nil + return nil } diff --git a/pkg/plugin/notify/notification.go b/pkg/plugin/notify/notification.go index 2083d018..2f0b43fa 100644 --- a/pkg/plugin/notify/notification.go +++ b/pkg/plugin/notify/notification.go @@ -31,7 +31,7 @@ type Notification struct { Email *Email `yaml:"email,omitempty"` Webhook *Webhook `yaml:"webhook,omitempty"` Hipchat *Hipchat `yaml:"hipchat,omitempty"` - Irc *IRC `yaml:"irc,omitempty"` + Irc *IRC `yaml:"irc,omitempty"` } func (n *Notification) Send(context *Context) error { @@ -50,10 +50,10 @@ func (n *Notification) Send(context *Context) error { n.Hipchat.Send(context) } - // send irc notifications - if n.Irc != nil { - n.Irc.Send(context) - } + // send irc notifications + if n.Irc != nil { + n.Irc.Send(context) + } return nil } diff --git a/pkg/plugin/publish/pypi.go b/pkg/plugin/publish/pypi.go index d46cd60c..30b1a5b2 100644 --- a/pkg/plugin/publish/pypi.go +++ b/pkg/plugin/publish/pypi.go @@ -1,2 +1 @@ package publish - diff --git a/pkg/template/template.go b/pkg/template/template.go index ed5d6b4b..95fe3e85 100644 --- a/pkg/template/template.go +++ b/pkg/template/template.go @@ -1,11 +1,11 @@ package template import ( + "crypto/md5" "errors" "fmt" "html/template" "io" - "crypto/md5" "strings" "github.com/GeertJohan/go.rice" @@ -99,7 +99,7 @@ func init() { h := md5.New() io.WriteString(h, mainjs) jshash := fmt.Sprintf("%x", h.Sum(nil)) - base = strings.Replace(base, "main.js", "main.js?h=" + jshash, 1) + base = strings.Replace(base, "main.js", "main.js?h="+jshash, 1) // extract the base form template as a string form, err := box.String("form.html") From 4cd5e69e7bff08a11acbc3f80840b9030c3ad051 Mon Sep 17 00:00:00 2001 From: Benjamin Manns Date: Thu, 6 Mar 2014 10:50:48 -0800 Subject: [PATCH 2/2] Remove unreachable return. --- pkg/build/build.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkg/build/build.go b/pkg/build/build.go index 337e5021..65f3a73e 100644 --- a/pkg/build/build.go +++ b/pkg/build/build.go @@ -121,8 +121,6 @@ func (b *Builder) Run() error { b.BuildState.Finished = time.Now().UTC().Unix() return nil } - - return nil } func (b *Builder) setup() error {