style: resovle linting issues

pull/26/head
kha7iq 4 years ago
parent 603aa5ee9e
commit edd49a3f16

@ -66,7 +66,7 @@ All configuration options are also available via environment variables.`,
discordSvc := discord.New()
if err := discordSvc.AuthenticateWithBotToken(discordOpts.Token); err != nil {
return fmt.Errorf("unable to authenticate %v\n", err)
return fmt.Errorf("unable to authenticate %v", err)
}
chn := strings.Split(discordOpts.Channel, ",")

@ -18,7 +18,7 @@ type matterMost struct {
Token string
ServerURL string
Scheme string
ApiURL string
APIURL string
Message string
ChanIDs string
}
@ -108,7 +108,7 @@ You can specify multiple channels by separating the value with ','.`,
EnvVars: []string{"MATTERMOST_SCHEME"},
},
&cli.StringFlag{
Destination: &mattermostOpts.ApiURL,
Destination: &mattermostOpts.APIURL,
Name: "api",
Value: "/api/v4/posts",
Usage: "Unless using older version of api default is fine.",
@ -116,7 +116,7 @@ You can specify multiple channels by separating the value with ','.`,
},
},
Action: func(ctx *cli.Context) error {
endPointURL := mattermostOpts.Scheme + "://" + mattermostOpts.ServerURL + mattermostOpts.ApiURL
endPointURL := mattermostOpts.Scheme + "://" + mattermostOpts.ServerURL + mattermostOpts.APIURL
// Create a Bearer string by appending string access token
bearer := "Bearer " + mattermostOpts.Token
@ -129,7 +129,7 @@ You can specify multiple channels by separating the value with ','.`,
return fmt.Errorf(EmptyChannel)
}
jsonData, err := toJson(v, fullMessage)
jsonData, err := toJSON(v, fullMessage)
if err != nil {
return fmt.Errorf("error parsing json\n[ERROR] - %v", err)
}
@ -137,7 +137,6 @@ You can specify multiple channels by separating the value with ','.`,
if err := sendMattermost(endPointURL, bearer, jsonData); err != nil {
return fmt.Errorf("failed to send message\n[ERROR] - %v", err)
}
}
return nil
},
@ -145,7 +144,7 @@ You can specify multiple channels by separating the value with ','.`,
}
// toJson takes strings and convert them to json byte array
func toJson(channel string, msg string) ([]byte, error) {
func toJSON(channel string, msg string) ([]byte, error) {
m := make(map[string]string, 2)
m["channel_id"] = channel
m["message"] = msg

@ -63,7 +63,6 @@ you can add permissions for multiple channels to single webhook.`,
return fmt.Errorf(EmptyChannel)
}
teamsSvc.AddReceivers(v)
}
notifier.UseServices(teamsSvc)

@ -105,7 +105,6 @@ Multiple device nicknames or numbers can be used separated by comma.`,
); err != nil {
return err
}
}
default:
pushBulletSvc := pushbullet.New(pushBulletOpts.Token)
@ -127,7 +126,6 @@ Multiple device nicknames or numbers can be used separated by comma.`,
); err != nil {
return err
}
}
log.Println("Successfully sent!")

@ -13,7 +13,7 @@ import (
type rocketChat struct {
Token string
UserId string
UserID string
Message string
Channel string
Title string
@ -43,7 +43,7 @@ All configuration options are also available via environment variables.`,
" --channel 'alert' --msg 'some message'",
Flags: []cli.Flag{
&cli.StringFlag{
Destination: &rocketChatOpts.UserId,
Destination: &rocketChatOpts.UserID,
Name: "userid",
Aliases: []string{"id"},
Required: true,
@ -99,7 +99,7 @@ All configuration options are also available via environment variables.`,
notifier := notify.New()
rocketChatSvc, err := rocketchat.New(rocketChatOpts.ServerURL, rocketChatOpts.Scheme,
rocketChatOpts.UserId, rocketChatOpts.Token)
rocketChatOpts.UserID, rocketChatOpts.Token)
if err != nil {
return err
}

@ -77,9 +77,9 @@ All configuration options are also available via environment variables.`,
if len(v) <= 0 {
return fmt.Errorf(EmptyChannel)
}
k, err := strconv.Atoi(v)
if err != nil {
log.Println(err)
k, errStr := strconv.Atoi(v)
if errStr != nil {
return errStr
}
telegramSvc.AddReceivers(int64(k))
}

Loading…
Cancel
Save