fix golint error

Signed-off-by: xuyasong <1154564309@qq.com>
This commit is contained in:
xuyasong 2019-03-15 17:48:36 +08:00
parent 8688c7b9ad
commit 60c9bf49c2
3 changed files with 23 additions and 23 deletions

View File

@ -26,7 +26,7 @@ import (
type alertAddCmd struct { type alertAddCmd struct {
annotations []string annotations []string
generatorUrl string generatorURL string
labels []string labels []string
start string start string
end string end string
@ -61,7 +61,7 @@ func configureAddAlertCmd(cc *kingpin.CmdClause) {
addCmd = cc.Command("add", alertAddHelp) addCmd = cc.Command("add", alertAddHelp)
) )
addCmd.Arg("labels", "List of labels to be included with the alert").StringsVar(&a.labels) addCmd.Arg("labels", "List of labels to be included with the alert").StringsVar(&a.labels)
addCmd.Flag("generator-url", "Set the URL of the source that generated the alert").StringVar(&a.generatorUrl) addCmd.Flag("generator-url", "Set the URL of the source that generated the alert").StringVar(&a.generatorURL)
addCmd.Flag("start", "Set when the alert should start. RFC3339 format 2006-01-02T15:04:05-07:00").StringVar(&a.start) addCmd.Flag("start", "Set when the alert should start. RFC3339 format 2006-01-02T15:04:05-07:00").StringVar(&a.start)
addCmd.Flag("end", "Set when the alert should should end. RFC3339 format 2006-01-02T15:04:05-07:00").StringVar(&a.end) addCmd.Flag("end", "Set when the alert should should end. RFC3339 format 2006-01-02T15:04:05-07:00").StringVar(&a.end)
addCmd.Flag("annotation", "Set an annotation to be included with the alert").StringsVar(&a.annotations) addCmd.Flag("annotation", "Set an annotation to be included with the alert").StringsVar(&a.annotations)
@ -112,6 +112,6 @@ func (a *alertAddCmd) addAlert(ctx context.Context, _ *kingpin.ParseContext) err
Annotations: annotations, Annotations: annotations,
StartsAt: startsAt, StartsAt: startsAt,
EndsAt: endsAt, EndsAt: endsAt,
GeneratorURL: a.generatorUrl, GeneratorURL: a.generatorURL,
}) })
} }

View File

@ -578,9 +578,9 @@ func (p *Peer) WaitReady() {
func (p *Peer) Status() string { func (p *Peer) Status() string {
if p.Ready() { if p.Ready() {
return "ready" return "ready"
} else {
return "settling"
} }
return "settling"
} }
// Info returns a JSON-serializable dump of cluster state. // Info returns a JSON-serializable dump of cluster state.

View File

@ -1113,25 +1113,25 @@ func (n *Wechat) Notify(ctx context.Context, as ...*types.Alert) (bool, error) {
if resp.StatusCode != 200 { if resp.StatusCode != 200 {
return true, fmt.Errorf("unexpected status code %v", resp.StatusCode) return true, fmt.Errorf("unexpected status code %v", resp.StatusCode)
} else {
var weResp weChatResponse
if err := json.Unmarshal(body, &weResp); err != nil {
return true, err
}
// https://work.weixin.qq.com/api/doc#10649
if weResp.Code == 0 {
return false, nil
}
// AccessToken is expired
if weResp.Code == 42001 {
n.accessToken = ""
return true, errors.New(weResp.Error)
}
return false, errors.New(weResp.Error)
} }
var weResp weChatResponse
if err := json.Unmarshal(body, &weResp); err != nil {
return true, err
}
// https://work.weixin.qq.com/api/doc#10649
if weResp.Code == 0 {
return false, nil
}
// AccessToken is expired
if weResp.Code == 42001 {
n.accessToken = ""
return true, errors.New(weResp.Error)
}
return false, errors.New(weResp.Error)
} }
// OpsGenie implements a Notifier for OpsGenie notifications. // OpsGenie implements a Notifier for OpsGenie notifications.