Skip to content

Commit 6aeef4e

Browse files
committed
👕 Fix Lint and Vet Errors
1 parent b173422 commit 6aeef4e

13 files changed

+107
-107
lines changed

examples/files/files.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func main() {
1919
fmt.Printf("%s\n", err)
2020
return
2121
}
22-
fmt.Printf("Name: %s, Url: %s\n", file.Name, file.URL)
22+
fmt.Printf("Name: %s, URL: %s\n", file.Name, file.URL)
2323

2424
err = api.DeleteFile(file.ID)
2525
if err != nil {

examples/reactions/reactions.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ func main() {
3939

4040
// Post as the authenticated user.
4141
postAsUserName = authTest.User
42-
postAsUserID = authTest.UserId
42+
postAsUserID = authTest.UserID
4343

4444
// Posting to DM with self causes a conversation with slackbot.
4545
postToUserName = authTest.User
46-
postToUserID = authTest.UserId
46+
postToUserID = authTest.UserID
4747

4848
// Find the channel.
4949
_, _, chanID, err := api.OpenIMChannel(postToUserID)

examples/websocket/websocket.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func main() {
1919
}
2020
go wsAPI.HandleIncomingEvents(chReceiver)
2121
go wsAPI.Keepalive(20 * time.Second)
22-
go func(wsAPI *slack.SlackWS, chSender chan slack.OutgoingMessage) {
22+
go func(wsAPI *slack.WS, chSender chan slack.OutgoingMessage) {
2323
for {
2424
select {
2525
case msg := <-chSender:
@@ -43,8 +43,8 @@ func main() {
4343
case slack.LatencyReport:
4444
a := msg.Data.(slack.LatencyReport)
4545
fmt.Printf("Current latency: %v\n", a.Value)
46-
case *slack.SlackWSError:
47-
error := msg.Data.(*slack.SlackWSError)
46+
case *slack.WSError:
47+
error := msg.Data.(*slack.WSError)
4848
fmt.Printf("Error: %d - %s\n", error.Code, error.Msg)
4949
default:
5050
fmt.Printf("Unexpected: %v\n", msg.Data)

info.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"time"
66
)
77

8-
// XXX: Need to implement
8+
// UserPrefs needs to be implemented
99
type UserPrefs struct {
1010
// "highlight_words":"",
1111
// "user_colors":"",
@@ -145,7 +145,7 @@ type Bot struct {
145145
// Info contains various details about Users, Channels, Bots and the authenticated user
146146
// It is returned by StartRTM
147147
type Info struct {
148-
Url string `json:"url,omitempty"`
148+
URL string `json:"url,omitempty"`
149149
User *UserDetails `json:"self,omitempty"`
150150
Team *Team `json:"team,omitempty"`
151151
Users []User `json:"users,omitempty"`
@@ -157,7 +157,7 @@ type Info struct {
157157

158158
type infoResponseFull struct {
159159
Info
160-
SlackWSResponse
160+
WSResponse
161161
}
162162

163163
// GetBotByID returns a bot given a bot id
@@ -190,10 +190,10 @@ func (info Info) GetChannelByID(channelID string) *Channel {
190190
return nil
191191
}
192192

193-
// GetGroupById returns a group given a group id
194-
func (info Info) GetGroupById(groupId string) *Group {
193+
// GetGroupByID returns a group given a group id
194+
func (info Info) GetGroupByID(groupID string) *Group {
195195
for _, group := range info.Groups {
196-
if group.Id == groupId {
196+
if group.ID == groupID {
197197
return &group
198198
}
199199
}

item.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -52,23 +52,23 @@ func NewGroupItem(ch string) Item {
5252
// CommentId, or the combination of ChannelId and Timestamp must be
5353
// specified.
5454
type ItemRef struct {
55-
ChannelId string `json:"channel"`
55+
Channel string `json:"channel"`
5656
Timestamp string `json:"timestamp"`
57-
FileId string `json:"file"`
58-
CommentId string `json:"file_comment"`
57+
File string `json:"file"`
58+
Comment string `json:"file_comment"`
5959
}
6060

6161
// NewRefToMessage initializes a reference to to a message.
62-
func NewRefToMessage(channelID, timestamp string) ItemRef {
63-
return ItemRef{ChannelId: channelID, Timestamp: timestamp}
62+
func NewRefToMessage(channel, timestamp string) ItemRef {
63+
return ItemRef{Channel: channel, Timestamp: timestamp}
6464
}
6565

6666
// NewRefToFile initializes a reference to a file.
67-
func NewRefToFile(fileID string) ItemRef {
68-
return ItemRef{FileId: fileID}
67+
func NewRefToFile(file string) ItemRef {
68+
return ItemRef{File: file}
6969
}
7070

7171
// NewRefToComment initializes a reference to a file comment.
72-
func NewRefToComment(commentID string) ItemRef {
73-
return ItemRef{CommentId: commentID}
72+
func NewRefToComment(comment string) ItemRef {
73+
return ItemRef{Comment: comment}
7474
}

item_test.go

+18-18
Original file line numberDiff line numberDiff line change
@@ -78,48 +78,48 @@ func TestNewGroupItem(t *testing.T) {
7878

7979
func TestNewRefToMessage(t *testing.T) {
8080
ref := NewRefToMessage("chan", "ts")
81-
if got, want := ref.ChannelId, "chan"; got != want {
82-
t.Errorf("ChannelId got %s, want %s", got, want)
81+
if got, want := ref.Channel, "chan"; got != want {
82+
t.Errorf("Channel got %s, want %s", got, want)
8383
}
8484
if got, want := ref.Timestamp, "ts"; got != want {
8585
t.Errorf("Timestamp got %s, want %s", got, want)
8686
}
87-
if got, want := ref.FileId, ""; got != want {
88-
t.Errorf("FileId got %s, want %s", got, want)
87+
if got, want := ref.File, ""; got != want {
88+
t.Errorf("File got %s, want %s", got, want)
8989
}
90-
if got, want := ref.CommentId, ""; got != want {
91-
t.Errorf("CommentId got %s, want %s", got, want)
90+
if got, want := ref.Comment, ""; got != want {
91+
t.Errorf("Comment got %s, want %s", got, want)
9292
}
9393
}
9494

9595
func TestNewRefToFile(t *testing.T) {
9696
ref := NewRefToFile("file")
97-
if got, want := ref.ChannelId, ""; got != want {
98-
t.Errorf("ChannelId got %s, want %s", got, want)
97+
if got, want := ref.Channel, ""; got != want {
98+
t.Errorf("Channel got %s, want %s", got, want)
9999
}
100100
if got, want := ref.Timestamp, ""; got != want {
101101
t.Errorf("Timestamp got %s, want %s", got, want)
102102
}
103-
if got, want := ref.FileId, "file"; got != want {
104-
t.Errorf("FileId got %s, want %s", got, want)
103+
if got, want := ref.File, "file"; got != want {
104+
t.Errorf("File got %s, want %s", got, want)
105105
}
106-
if got, want := ref.CommentId, ""; got != want {
107-
t.Errorf("CommentId got %s, want %s", got, want)
106+
if got, want := ref.Comment, ""; got != want {
107+
t.Errorf("Comment got %s, want %s", got, want)
108108
}
109109
}
110110

111111
func TestNewRefToComment(t *testing.T) {
112112
ref := NewRefToComment("file_comment")
113-
if got, want := ref.ChannelId, ""; got != want {
114-
t.Errorf("ChannelId got %s, want %s", got, want)
113+
if got, want := ref.Channel, ""; got != want {
114+
t.Errorf("Channel got %s, want %s", got, want)
115115
}
116116
if got, want := ref.Timestamp, ""; got != want {
117117
t.Errorf("Timestamp got %s, want %s", got, want)
118118
}
119-
if got, want := ref.FileId, ""; got != want {
120-
t.Errorf("FileId got %s, want %s", got, want)
119+
if got, want := ref.File, ""; got != want {
120+
t.Errorf("File got %s, want %s", got, want)
121121
}
122-
if got, want := ref.CommentId, "file_comment"; got != want {
123-
t.Errorf("CommentId got %s, want %s", got, want)
122+
if got, want := ref.Comment, "file_comment"; got != want {
123+
t.Errorf("Comment got %s, want %s", got, want)
124124
}
125125
}

messages.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,12 @@ type Pong struct {
102102
}
103103

104104
// NewOutgoingMessage prepares an OutgoingMessage that the user can use to send a message
105-
func (api *SlackWS) NewOutgoingMessage(text string, channel string) *OutgoingMessage {
105+
func (api *WS) NewOutgoingMessage(text string, channel string) *OutgoingMessage {
106106
api.mutex.Lock()
107107
defer api.mutex.Unlock()
108-
api.messageId++
108+
api.messageID++
109109
return &OutgoingMessage{
110-
ID: api.messageId,
110+
ID: api.messageID,
111111
Type: "message",
112112
Channel: channel,
113113
Text: text,

reactions.go

+32-32
Original file line numberDiff line numberDiff line change
@@ -59,28 +59,28 @@ func (res getReactionsResponseFull) extractReactions() []ItemReaction {
5959
}
6060

6161
const (
62-
DEFAULT_REACTIONS_USERID = ""
63-
DEFAULT_REACTIONS_COUNT = 100
64-
DEFAULT_REACTIONS_PAGE = 1
65-
DEFAULT_REACTIONS_FULL = false
62+
DEFAULT_REACTIONS_USER = ""
63+
DEFAULT_REACTIONS_COUNT = 100
64+
DEFAULT_REACTIONS_PAGE = 1
65+
DEFAULT_REACTIONS_FULL = false
6666
)
6767

6868
// ListReactionsParameters is the inputs to find all reactions by a user.
6969
type ListReactionsParameters struct {
70-
UserId string
71-
Count int
72-
Page int
73-
Full bool
70+
User string
71+
Count int
72+
Page int
73+
Full bool
7474
}
7575

7676
// NewListReactionsParameters initializes the inputs to find all reactions
7777
// performed by a user.
7878
func NewListReactionsParameters() ListReactionsParameters {
7979
return ListReactionsParameters{
80-
UserId: DEFAULT_REACTIONS_USERID,
81-
Count: DEFAULT_REACTIONS_COUNT,
82-
Page: DEFAULT_REACTIONS_PAGE,
83-
Full: DEFAULT_REACTIONS_FULL,
80+
User: DEFAULT_REACTIONS_USER,
81+
Count: DEFAULT_REACTIONS_COUNT,
82+
Page: DEFAULT_REACTIONS_PAGE,
83+
Full: DEFAULT_REACTIONS_FULL,
8484
}
8585
}
8686

@@ -136,17 +136,17 @@ func (api *Slack) AddReaction(name string, item ItemRef) error {
136136
if name != "" {
137137
values.Set("name", name)
138138
}
139-
if item.ChannelId != "" {
140-
values.Set("channel", string(item.ChannelId))
139+
if item.Channel != "" {
140+
values.Set("channel", string(item.Channel))
141141
}
142142
if item.Timestamp != "" {
143143
values.Set("timestamp", string(item.Timestamp))
144144
}
145-
if item.FileId != "" {
146-
values.Set("file", string(item.FileId))
145+
if item.File != "" {
146+
values.Set("file", string(item.File))
147147
}
148-
if item.CommentId != "" {
149-
values.Set("file_comment", string(item.CommentId))
148+
if item.Comment != "" {
149+
values.Set("file_comment", string(item.Comment))
150150
}
151151
response := &SlackResponse{}
152152
if err := parseResponse("reactions.add", values, response, api.debug); err != nil {
@@ -166,17 +166,17 @@ func (api *Slack) RemoveReaction(name string, item ItemRef) error {
166166
if name != "" {
167167
values.Set("name", name)
168168
}
169-
if item.ChannelId != "" {
170-
values.Set("channel", string(item.ChannelId))
169+
if item.Channel != "" {
170+
values.Set("channel", string(item.Channel))
171171
}
172172
if item.Timestamp != "" {
173173
values.Set("timestamp", string(item.Timestamp))
174174
}
175-
if item.FileId != "" {
176-
values.Set("file", string(item.FileId))
175+
if item.File != "" {
176+
values.Set("file", string(item.File))
177177
}
178-
if item.CommentId != "" {
179-
values.Set("file_comment", string(item.CommentId))
178+
if item.Comment != "" {
179+
values.Set("file_comment", string(item.Comment))
180180
}
181181
response := &SlackResponse{}
182182
if err := parseResponse("reactions.remove", values, response, api.debug); err != nil {
@@ -193,17 +193,17 @@ func (api *Slack) GetReactions(item ItemRef, params GetReactionsParameters) ([]I
193193
values := url.Values{
194194
"token": {api.config.token},
195195
}
196-
if item.ChannelId != "" {
197-
values.Set("channel", string(item.ChannelId))
196+
if item.Channel != "" {
197+
values.Set("channel", string(item.Channel))
198198
}
199199
if item.Timestamp != "" {
200200
values.Set("timestamp", string(item.Timestamp))
201201
}
202-
if item.FileId != "" {
203-
values.Set("file", string(item.FileId))
202+
if item.File != "" {
203+
values.Set("file", string(item.File))
204204
}
205-
if item.CommentId != "" {
206-
values.Set("file_comment", string(item.CommentId))
205+
if item.Comment != "" {
206+
values.Set("file_comment", string(item.Comment))
207207
}
208208
if params.Full != DEFAULT_REACTIONS_FULL {
209209
values.Set("full", strconv.FormatBool(params.Full))
@@ -223,8 +223,8 @@ func (api *Slack) ListReactions(params ListReactionsParameters) ([]ReactedItem,
223223
values := url.Values{
224224
"token": {api.config.token},
225225
}
226-
if params.UserId != DEFAULT_REACTIONS_USERID {
227-
values.Add("user", params.UserId)
226+
if params.User != DEFAULT_REACTIONS_USER {
227+
values.Add("user", params.User)
228228
}
229229
if params.Count != DEFAULT_REACTIONS_COUNT {
230230
values.Add("count", strconv.Itoa(params.Count))

reactions_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -337,13 +337,13 @@ func TestSlack_ListReactions(t *testing.T) {
337337
},
338338
}
339339
wantParams := map[string]string{
340-
"user": "UserID",
340+
"user": "User",
341341
"count": "200",
342342
"page": "2",
343343
"full": "true",
344344
}
345345
params := NewListReactionsParameters()
346-
params.UserId = "UserID"
346+
params.User = "User"
347347
params.Count = 200
348348
params.Page = 2
349349
params.Full = true

slack.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type SlackResponse struct {
1717
}
1818

1919
type AuthTestResponse struct {
20-
Url string `json:"url"`
20+
URL string `json:"url"`
2121
Team string `json:"team"`
2222
User string `json:"user"`
2323
TeamID string `json:"team_id"`

stars_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -118,18 +118,18 @@ func TestSlack_GetStarred(t *testing.T) {
118118
for i, test := range tests {
119119
sh = newStarsHandler()
120120
sh.response = test.json
121-
response_items, response_paging, err := api.GetStarred(test.params)
121+
responseItems, responsePaging, err := api.GetStarred(test.params)
122122
if err != nil {
123123
t.Fatalf("%d Unexpected error: %s", i, err)
124124
}
125125
if !reflect.DeepEqual(sh.gotParams, test.wantParams) {
126126
t.Errorf("%d got %v; want %v", i, sh.gotParams, test.wantParams)
127127
}
128-
if !reflect.DeepEqual(response_items, test.starredItems) {
129-
t.Errorf("%d got %v; want %v", i, response_items, test.starredItems)
128+
if !reflect.DeepEqual(responseItems, test.starredItems) {
129+
t.Errorf("%d got %v; want %v", i, responseItems, test.starredItems)
130130
}
131-
if !reflect.DeepEqual(response_paging, test.paging) {
132-
t.Errorf("%d got %v; want %v", i, response_paging, test.paging)
131+
if !reflect.DeepEqual(responsePaging, test.paging) {
132+
t.Errorf("%d got %v; want %v", i, responsePaging, test.paging)
133133
}
134134
}
135135
}

0 commit comments

Comments
 (0)