Skip to content

Commit

Permalink
docs: golint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
SevereCloud committed Jan 6, 2020
1 parent 6dfc18a commit f4997d3
Show file tree
Hide file tree
Showing 20 changed files with 85 additions and 55 deletions.
58 changes: 42 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,52 @@ go get github.com/SevereCloud/vksdk@latest
package main

import (
"log"
"log"

"github.com/SevereCloud/vksdk/api"
"github.com/SevereCloud/vksdk/api"
"github.com/SevereCloud/vksdk/api/params"
"github.com/SevereCloud/vksdk/longpoll-bot"
"github.com/SevereCloud/vksdk/object"
)

func main() {
vk := api.Init("<TOKEN>") // рекомендуется использовать os.Getenv("TOKEN")

params := api.Params{
"user_ids": 1
}

users, err := vk.UsersGet(params)
if err != nil {
log.Fatal(err)
}

for _, user := range users {
log.Printf("Пользователя с id%d зовут %s %s\n", user.ID, user.FirstName, user.LastName)
}
token := "<TOKEN>" // рекомендуется использовать os.Getenv("TOKEN")
vk := api.Init(token)

// Получаем информацию о группе
group, err := vk.GroupsGetByID(api.Params{})
if err != nil {
log.Fatal(err)
}

// Иницилизируем longpoll
lp, err := longpoll.Init(vk, group[0].ID)
if err != nil {
log.Fatal(err)
}

// Событие нового сообщения
lp.MessageNew(func(obj object.MessageNewObject, groupID int) {
log.Printf("%d: %s", obj.Message.PeerID, obj.Message.Text)

if obj.Message.Text == "ping" {
b := params.NewMessagesSendBuilder()
b.Message("pong")
b.RandomID(0)
b.PeerID(obj.Message.PeerID)

_, err := vk.MessagesSend(b.Params)
if err != nil {
log.Fatal(err)
}
}
})

// Запускаем Bots Longpoll
log.Println("Start longpoll")
if err := lp.Run(); err != nil {
log.Fatal(err)
}
}
```

Expand Down
1 change: 1 addition & 0 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/SevereCloud/vksdk/object"
)

// Api constants
const (
Version = "5.103"
APIMethodURL = "https://api.vk.com/method/"
Expand Down
4 changes: 2 additions & 2 deletions api/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ func (errorType ErrorType) New(msg string) error {
return customError{errorType: errorType, originalError: errors.New(msg)}
}

// New creates a new customError with formatted message
// Newf creates a new customError with formatted message
func (errorType ErrorType) Newf(msg string, args ...interface{}) error {
return customError{errorType: errorType, originalError: fmt.Errorf(msg, args...)}
}
Expand All @@ -297,7 +297,7 @@ func (errorType ErrorType) Wrap(err error, msg string) error {
return errorType.Wrapf(err, msg)
}

// Wrap creates a new wrapped error with formatted message
// Wrapf creates a new wrapped error with formatted message
func (errorType ErrorType) Wrapf(err error, msg string, args ...interface{}) error {
return customError{errorType: errorType, originalError: errors.Wrapf(err, msg, args...)}
}
Expand Down
2 changes: 1 addition & 1 deletion api/friends.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func (vk *VK) FriendsGetOnline(params Params) (response []int, err error) {
return
}

// FriendsGetOnlineResponse struct
// FriendsGetOnlineOnlineMobileResponse struct
type FriendsGetOnlineOnlineMobileResponse struct {
Online []int `json:"online"`
OnlineMobile []int `json:"online_mobile"`
Expand Down
2 changes: 1 addition & 1 deletion api/newsfeed.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func (vk *VK) NewsfeedGetSuggestedSources(params Params) (response NewsfeedGetSu
return
}

// NewsfeedIgnoreItemHides an item from the newsfeed.
// NewsfeedIgnoreItem Hides an item from the newsfeed.
//
// https://vk.com/dev/newsfeed.ignoreItem
func (vk *VK) NewsfeedIgnoreItem(params Params) (response int, err error) {
Expand Down
3 changes: 2 additions & 1 deletion api/params/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,9 +475,10 @@ func (b *AccountSetSilenceModeBuilder) PeerID(v int) {
b.Params["peer_id"] = v
}

// Sound
// Sound parameter
//
// * 1 — to enable sound in this dialog,
//
// * 0 — to disable sound. Only if 'peer_id' contains user or community ID.
func (b *AccountSetSilenceModeBuilder) Sound(v int) {
b.Params["sound"] = v
Expand Down
2 changes: 1 addition & 1 deletion api/params/ads.go
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ func (b *AdsGetTargetGroupsBuilder) ClientID(v int) {
b.Params["client_id"] = v
}

// Extended
// Extended parameter
//
// * 1 — to return pixel code.
func (b *AdsGetTargetGroupsBuilder) Extended(v bool) {
Expand Down
3 changes: 2 additions & 1 deletion api/params/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ func (b *AppsGetCatalogBuilder) Platform(v string) {
b.Params["platform"] = v
}

// Extended
// Extended parameter
//
// * 1 — to return additional fields 'screenshots', 'MAU', 'catalog_position', and 'international'.
// If set, 'count' must be less than or equal to '100'.
//
Expand Down
4 changes: 2 additions & 2 deletions api/params/board.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ func (b *BoardGetTopicsBuilder) Count(v int) {
b.Params["count"] = v
}

// Extended
// Extended parameter
//
// * 1 — to return information about users who created topics or who posted there last,
//
Expand All @@ -392,7 +392,7 @@ func (b *BoardGetTopicsBuilder) Extended(v bool) {
b.Params["extended"] = v
}

// Preview
// Preview parameter
//
// * 1 — to return the first comment in each topic;
//
Expand Down
4 changes: 2 additions & 2 deletions api/params/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (b *DatabaseGetCitiesBuilder) Q(v string) {
b.Params["q"] = v
}

// NeedAll
// NeedAll parameter
//
// * 1 — to return all cities in the country,
//
Expand Down Expand Up @@ -114,7 +114,7 @@ func NewDatabaseGetCountriesBuilder() *DatabaseGetCountriesBuilder {
return &DatabaseGetCountriesBuilder{api.Params{}}
}

// NeedAll
// NeedAll parameter
//
// * 1 — to return a full list of all countries,
//
Expand Down
14 changes: 7 additions & 7 deletions api/params/friends.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (b *FriendsAreFriendsBuilder) UserIDs(v []int) {
b.Params["user_ids"] = v
}

// NeedSign
// NeedSign parameter
//
// * 1 — to return 'sign' field. 'sign' is md5("{id}_{user_id}_{friends_status}_{application_secret}"),
// where id is current user ID. This field allows to check that data has not been modified by the client.
Expand Down Expand Up @@ -309,7 +309,7 @@ func (b *FriendsGetListsBuilder) UserID(v int) {
b.Params["user_id"] = v
}

// ReturnSystem
// ReturnSystem parameter
//
// * 1 — to return system friend lists. By default: '0'.
func (b *FriendsGetListsBuilder) ReturnSystem(v bool) {
Expand Down Expand Up @@ -384,7 +384,7 @@ func (b *FriendsGetOnlineBuilder) ListID(v int) {
b.Params["list_id"] = v
}

// OnlineMobile
// OnlineMobile parameter
//
// * 1 — to return an additional 'online_mobile' field, '0' — (default),
func (b *FriendsGetOnlineBuilder) OnlineMobile(v bool) {
Expand Down Expand Up @@ -449,22 +449,22 @@ func (b *FriendsGetRequestsBuilder) Count(v int) {
b.Params["count"] = v
}

// Extended
// Extended parameter
//
// * 1 — to return response messages from users who have sent a friend request or,
// if 'suggested' is set to '1', to return a list of suggested friends
func (b *FriendsGetRequestsBuilder) Extended(v bool) {
b.Params["extended"] = v
}

// NeedMutual
// NeedMutual parameter
//
// * 1 — to return a list of mutual friends (up to 20), if any
func (b *FriendsGetRequestsBuilder) NeedMutual(v bool) {
b.Params["need_mutual"] = v
}

// Out
// Out parameter
//
// * 1 — to return outgoing requests, '0' — to return incoming requests (default)
func (b *FriendsGetRequestsBuilder) Out(v bool) {
Expand All @@ -483,7 +483,7 @@ func (b *FriendsGetRequestsBuilder) NeedViewed(v bool) {
b.Params["need_viewed"] = v
}

// Suggested
// Suggested parameter
//
// * 1 — to return a list of suggested friends, '0' — to return friend requests (default)
func (b *FriendsGetRequestsBuilder) Suggested(v bool) {
Expand Down
2 changes: 1 addition & 1 deletion api/params/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,7 @@ func (b *GroupsGetBuilder) UserID(v int) {
b.Params["user_id"] = v
}

// Extended
// Extended parameter
//
// * 1 — to return complete information about a user's communities,
//
Expand Down
4 changes: 2 additions & 2 deletions api/params/market.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ func (b *MarketGetBuilder) Offset(v int) {
b.Params["offset"] = v
}

// Extended
// Extended parameter
//
// * 1 – method will return additional fields: 'likes, can_comment, car_repost, photos'.
// These parameters are not returned by default.
Expand Down Expand Up @@ -601,7 +601,7 @@ func (b *MarketGetCommentsBuilder) Sort(v string) {
b.Params["sort"] = v
}

// Extended
// Extended parameter
//
// * 1 — comments will be returned as numbered objects, in addition lists of
// 'profiles' and 'groups' objects will be returned.
Expand Down
4 changes: 2 additions & 2 deletions api/params/video.go
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ func (b *VideoSaveBuilder) Description(v string) {
b.Params["description"] = v
}

// IsPrivate
// IsPrivate parameter
//
// * 1 — to designate the video as private (send it via a private message), the video will not appear
// on the user's video list and will not be available by ID for other users,
Expand All @@ -880,7 +880,7 @@ func (b *VideoSaveBuilder) IsPrivate(v bool) {
b.Params["is_private"] = v
}

// Wallpost
// Wallpost parameter
//
// * 1 — to post the saved video on a user's wall
// * 0 — not to post the saved video on a user's wall
Expand Down
24 changes: 12 additions & 12 deletions api/podcasts.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ type PodcastsGetCatalogResponse struct {
Items []object.PodcastsItem `json:"items"`
}

// PodcastsGetCatalog
// PodcastsGetCatalog method
//
// extended=0 method
// extended=0
//
// https://vk.com/dev/podcasts.getCatalog
func (vk *VK) PodcastsGetCatalog(params Params) (response PodcastsGetCatalogResponse, err error) {
Expand All @@ -27,9 +27,9 @@ type PodcastsGetCatalogExtendedResponse struct {
object.ExtendedResponse
}

// PodcastsGetCatalogExtended
// PodcastsGetCatalogExtended method
//
// extended=1 method
// extended=1
//
// https://vk.com/dev/podcasts.getCatalog
func (vk *VK) PodcastsGetCatalogExtended(params Params) (response PodcastsGetCatalogExtendedResponse, err error) {
Expand Down Expand Up @@ -70,9 +70,9 @@ type PodcastsGetFeedResponse struct {
NextFrom string `json:"next_from"`
}

// PodcastsGetFeed
// PodcastsGetFeed method
//
// extended=0 method
// extended=0
//
// https://vk.com/dev/podcasts.getFeed
func (vk *VK) PodcastsGetFeed(params Params) (response PodcastsGetFeedResponse, err error) {
Expand All @@ -89,9 +89,9 @@ type PodcastsGetFeedExtendedResponse struct {
object.ExtendedResponse
}

// PodcastsGetFeedExtended
// PodcastsGetFeedExtended method
//
// extended=1 method
// extended=1
//
// https://vk.com/dev/podcasts.getFeed
func (vk *VK) PodcastsGetFeedExtended(params Params) (response PodcastsGetFeedExtendedResponse, err error) {
Expand All @@ -118,9 +118,9 @@ type PodcastsGetStartPageResponse struct {
} `json:"catalog"`
}

// PodcastsGetStartPage
// PodcastsGetStartPage method
//
// extended=0 method
// extended=0
//
// https://vk.com/dev/podcasts.getStartPage
func (vk *VK) PodcastsGetStartPage(params Params) (response PodcastsGetStartPageResponse, err error) {
Expand Down Expand Up @@ -148,9 +148,9 @@ type PodcastsGetStartPageExtendedResponse struct {
object.ExtendedResponse
}

// PodcastsGetStartPageExtended
// PodcastsGetStartPageExtended method
//
// extended=1 method
// extended=1
//
// https://vk.com/dev/podcasts.getStartPage
func (vk *VK) PodcastsGetStartPageExtended(params Params) (response PodcastsGetStartPageExtendedResponse, err error) {
Expand Down
2 changes: 1 addition & 1 deletion api/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ func (vk *VK) UploadMessagesDoc(peerID int, typeDoc, title, tags string, file io
return
}

// UploadOwneCoverrPhoto uploading a Main Photo to a Group Chat
// UploadOwnerCoverPhoto uploading a Main Photo to a Group Chat
//
// Supported formats: JPG, PNG, GIF.
//
Expand Down
2 changes: 1 addition & 1 deletion object/appwidgets.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type AppWidgetsGroupImageUploadResponse struct {
Hash string `json:"hash"`
}

// AppWidgetsImagestruct
// AppWidgetsImage struct
type AppWidgetsImage struct {
ID string `json:"id"`
Type string `json:"type"`
Expand Down
2 changes: 1 addition & 1 deletion object/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type DocsDocPreviewGraffiti struct {
Height int `json:"height"`
}

// DocsDocPreviewVideo struct
// DocsDocPreviewVideo struct
type DocsDocPreviewVideo struct {
FileSize int `json:"file_size"` // Video file size in bites
Height int `json:"height"` // Video's height in pixels
Expand Down
1 change: 1 addition & 0 deletions object/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type MessageNewObject struct {
ClientInfo ClientInfo `json:"client_info"`
}

// UnmarshalJSON func
func (a *MessageNewObject) UnmarshalJSON(b []byte) (err error) {
type r MessageNewObject

Expand Down
Loading

0 comments on commit f4997d3

Please sign in to comment.