From be120ccde99c5632b5b0107112e82330ced143ad Mon Sep 17 00:00:00 2001 From: chaoqun <27287694+OpenWaygate@users.noreply.github.com> Date: Sun, 5 May 2024 21:51:13 +0800 Subject: [PATCH] :recycle: Export return type of exported func --- pkg/yutuber/activity.go | 8 ++--- pkg/yutuber/channel.go | 16 ++++----- pkg/yutuber/i18nLanguage.go | 4 +-- pkg/yutuber/i18nRegion.go | 4 +-- pkg/yutuber/member.go | 8 ++--- pkg/yutuber/membershipsLevel.go | 6 ++-- pkg/yutuber/playlist.go | 24 +++++++------- pkg/yutuber/playlistItem.go | 24 +++++++------- pkg/yutuber/search.go | 2 +- pkg/yutuber/video.go | 48 +++++++++++++-------------- pkg/yutuber/videoAbuseReportReason.go | 6 ++-- pkg/yutuber/videoCategory.go | 8 ++--- 12 files changed, 79 insertions(+), 79 deletions(-) diff --git a/pkg/yutuber/activity.go b/pkg/yutuber/activity.go index c0bff09..02d380f 100644 --- a/pkg/yutuber/activity.go +++ b/pkg/yutuber/activity.go @@ -11,7 +11,7 @@ import ( ) var ( - errGetActivity error = errors.New("failed to get activity") + errGetActivity = errors.New("failed to get activity") ) type activity struct { @@ -23,9 +23,9 @@ type Activity interface { get([]string) []*youtube.Activity } -type activityOption func(*activity) +type ActivityOption func(*activity) -func NewActivity(opts ...activityOption) Activity { +func NewActivity(opts ...ActivityOption) Activity { a := &activity{} for _, opt := range opts { @@ -67,7 +67,7 @@ func (a *activity) List(parts []string, output string) { } } -func WithActivityChannelId(channelId string) activityOption { +func WithActivityChannelId(channelId string) ActivityOption { return func(a *activity) { a.channelId = channelId } diff --git a/pkg/yutuber/channel.go b/pkg/yutuber/channel.go index b8ac83b..e46315f 100644 --- a/pkg/yutuber/channel.go +++ b/pkg/yutuber/channel.go @@ -13,8 +13,8 @@ import ( var ( service *youtube.Service - errGetChannel error = errors.New("failed to get channel") - errUpdateChannel error = errors.New("failed to update channel") + errGetChannel = errors.New("failed to get channel") + errUpdateChannel = errors.New("failed to update channel") ) type channel struct { @@ -30,9 +30,9 @@ type Channel interface { get([]string) []*youtube.Channel } -type channelOption func(*channel) +type ChannelOption func(*channel) -func NewChannel(opts ...channelOption) Channel { +func NewChannel(opts ...ChannelOption) Channel { c := &channel{} service = auth.NewY2BService() @@ -96,25 +96,25 @@ func (c *channel) Update() { utils.PrintJSON(res) } -func WithChannelID(id string) channelOption { +func WithChannelID(id string) ChannelOption { return func(c *channel) { c.id = id } } -func WithChannelTitle(title string) channelOption { +func WithChannelTitle(title string) ChannelOption { return func(c *channel) { c.title = title } } -func WithChannelDesc(desc string) channelOption { +func WithChannelDesc(desc string) ChannelOption { return func(c *channel) { c.desc = desc } } -func WithChannelUser(user string) channelOption { +func WithChannelUser(user string) ChannelOption { return func(c *channel) { c.user = user } diff --git a/pkg/yutuber/i18nLanguage.go b/pkg/yutuber/i18nLanguage.go index 983f8ef..66375ec 100644 --- a/pkg/yutuber/i18nLanguage.go +++ b/pkg/yutuber/i18nLanguage.go @@ -20,9 +20,9 @@ type I18nLanguage interface { List(parts []string, output string) } -type i18nLanguageOption func(*i18nLanguage) +type I18nLanguageOption func(*i18nLanguage) -func NewI18nLanguage(opts ...i18nLanguageOption) I18nLanguage { +func NewI18nLanguage(opts ...I18nLanguageOption) I18nLanguage { service = auth.NewY2BService() i := &i18nLanguage{} diff --git a/pkg/yutuber/i18nRegion.go b/pkg/yutuber/i18nRegion.go index ceb9298..a31048e 100644 --- a/pkg/yutuber/i18nRegion.go +++ b/pkg/yutuber/i18nRegion.go @@ -20,9 +20,9 @@ type I18nRegion interface { List(parts []string, output string) } -type i18nRegionOption func(*i18nRegion) +type I18nRegionOption func(*i18nRegion) -func NewI18nRegion(opts ...i18nRegionOption) I18nRegion { +func NewI18nRegion(opts ...I18nRegionOption) I18nRegion { service = auth.NewY2BService() i := &i18nRegion{} diff --git a/pkg/yutuber/member.go b/pkg/yutuber/member.go index 8aa9e19..61b7b11 100644 --- a/pkg/yutuber/member.go +++ b/pkg/yutuber/member.go @@ -10,7 +10,7 @@ import ( ) var ( - errGetMember error = errors.New("failed to get member") + errGetMember = errors.New("failed to get member") ) type member struct { @@ -22,9 +22,9 @@ type Member interface { get([]string) []*youtube.Member } -type memberOption func(*member) +type MemberOption func(*member) -func NewMember(opts ...memberOption) Member { +func NewMember(opts ...MemberOption) Member { m := &member{} service = auth.NewY2BService() @@ -67,7 +67,7 @@ func (m *member) List(parts []string, output string) { } } -func WithMemberChannelId(channelId string) memberOption { +func WithMemberChannelId(channelId string) MemberOption { return func(m *member) { m.memberChannelId = channelId } diff --git a/pkg/yutuber/membershipsLevel.go b/pkg/yutuber/membershipsLevel.go index 5c98145..b461349 100644 --- a/pkg/yutuber/membershipsLevel.go +++ b/pkg/yutuber/membershipsLevel.go @@ -10,7 +10,7 @@ import ( ) var ( - errGetMembershipsLevel error = errors.New("failed to get memberships level") + errGetMembershipsLevel = errors.New("failed to get memberships level") ) type membershipsLevel struct{} @@ -20,9 +20,9 @@ type MembershipsLevel interface { get([]string) []*youtube.MembershipsLevel } -type membershipsLevelOption func(*membershipsLevel) +type MembershipsLevelOption func(*membershipsLevel) -func NewMembershipsLevel(opts ...membershipsLevelOption) MembershipsLevel { +func NewMembershipsLevel(opts ...MembershipsLevelOption) MembershipsLevel { m := &membershipsLevel{} service = auth.NewY2BService() diff --git a/pkg/yutuber/playlist.go b/pkg/yutuber/playlist.go index 4998f62..fdbf713 100644 --- a/pkg/yutuber/playlist.go +++ b/pkg/yutuber/playlist.go @@ -12,9 +12,9 @@ import ( ) var ( - errGetPlaylist error = errors.New("failed to get playlist") - errInsertPlaylist error = errors.New("failed to insert playlist") - errUpdatePlaylist error = errors.New("failed to update playlist") + errGetPlaylist = errors.New("failed to get playlist") + errInsertPlaylist = errors.New("failed to insert playlist") + errUpdatePlaylist = errors.New("failed to update playlist") ) type playlist struct { @@ -34,9 +34,9 @@ type Playlist interface { get([]string) []*youtube.Playlist } -type playlistOption func(*playlist) +type PlaylistOption func(*playlist) -func NewPlaylist(opts ...playlistOption) Playlist { +func NewPlaylist(opts ...PlaylistOption) Playlist { p := &playlist{} service = auth.NewY2BService() @@ -133,43 +133,43 @@ func (p *playlist) get(parts []string) []*youtube.Playlist { return res.Items } -func WithPlaylistId(id string) playlistOption { +func WithPlaylistId(id string) PlaylistOption { return func(p *playlist) { p.id = id } } -func WithPlaylistTitle(title string) playlistOption { +func WithPlaylistTitle(title string) PlaylistOption { return func(p *playlist) { p.title = title } } -func WithPlaylistDesc(desc string) playlistOption { +func WithPlaylistDesc(desc string) PlaylistOption { return func(p *playlist) { p.desc = desc } } -func WithPlaylistTags(tags []string) playlistOption { +func WithPlaylistTags(tags []string) PlaylistOption { return func(p *playlist) { p.tags = tags } } -func WithPlaylistLanguage(language string) playlistOption { +func WithPlaylistLanguage(language string) PlaylistOption { return func(p *playlist) { p.language = language } } -func WithPlaylistChannelId(channelId string) playlistOption { +func WithPlaylistChannelId(channelId string) PlaylistOption { return func(p *playlist) { p.channelId = channelId } } -func WithPlaylistPrivacy(privacy string) playlistOption { +func WithPlaylistPrivacy(privacy string) PlaylistOption { return func(p *playlist) { p.privacy = privacy } diff --git a/pkg/yutuber/playlistItem.go b/pkg/yutuber/playlistItem.go index 5219455..a48dcaf 100644 --- a/pkg/yutuber/playlistItem.go +++ b/pkg/yutuber/playlistItem.go @@ -11,9 +11,9 @@ import ( ) var ( - errGetPlaylistItem error = fmt.Errorf("failed to get playlist item") - errUpdatePlaylistItem error = fmt.Errorf("failed to update playlist item") - errInsertPlaylistItem error = fmt.Errorf("failed to insert playlist item") + errGetPlaylistItem = fmt.Errorf("failed to get playlist item") + errUpdatePlaylistItem = fmt.Errorf("failed to update playlist item") + errInsertPlaylistItem = fmt.Errorf("failed to insert playlist item") ) type playlistItem struct { @@ -33,9 +33,9 @@ type PlaylistItem interface { get([]string) []*youtube.PlaylistItem } -type playlistItemOption func(*playlistItem) +type PlaylistItemOption func(*playlistItem) -func NewPlaylistItem(opts ...playlistItemOption) PlaylistItem { +func NewPlaylistItem(opts ...PlaylistItemOption) PlaylistItem { p := &playlistItem{} service = auth.NewY2BService() @@ -123,43 +123,43 @@ func (pi *playlistItem) get(parts []string) []*youtube.PlaylistItem { return response.Items } -func WithPlaylistItemId(id string) playlistItemOption { +func WithPlaylistItemId(id string) PlaylistItemOption { return func(p *playlistItem) { p.id = id } } -func WithPlaylistItemTitle(title string) playlistItemOption { +func WithPlaylistItemTitle(title string) PlaylistItemOption { return func(p *playlistItem) { p.title = title } } -func WithPlaylistItemDesc(desc string) playlistItemOption { +func WithPlaylistItemDesc(desc string) PlaylistItemOption { return func(p *playlistItem) { p.desc = desc } } -func WithPlaylistItemVideoId(videoId string) playlistItemOption { +func WithPlaylistItemVideoId(videoId string) PlaylistItemOption { return func(p *playlistItem) { p.videoId = videoId } } -func WithPlaylistItemPlaylistId(playlistId string) playlistItemOption { +func WithPlaylistItemPlaylistId(playlistId string) PlaylistItemOption { return func(p *playlistItem) { p.playlistId = playlistId } } -func WithPlaylistItemChannelId(channelId string) playlistItemOption { +func WithPlaylistItemChannelId(channelId string) PlaylistItemOption { return func(p *playlistItem) { p.channelId = channelId } } -func WithPlaylistItemPrivacy(privacy string) playlistItemOption { +func WithPlaylistItemPrivacy(privacy string) PlaylistItemOption { return func(p *playlistItem) { p.privacy = privacy } diff --git a/pkg/yutuber/search.go b/pkg/yutuber/search.go index 3ae1451..480e08f 100644 --- a/pkg/yutuber/search.go +++ b/pkg/yutuber/search.go @@ -10,7 +10,7 @@ import ( ) var ( - errGetSearch error = errors.New("failed to get search") + errGetSearch = errors.New("failed to get search") ) type search struct { diff --git a/pkg/yutuber/video.go b/pkg/yutuber/video.go index 147ff5d..3a6f683 100644 --- a/pkg/yutuber/video.go +++ b/pkg/yutuber/video.go @@ -12,13 +12,13 @@ import ( ) var ( - errGetVideo error = errors.New("failed to get video") - errInsertVideo error = errors.New("failed to insert video") - errUpdateVideo error = errors.New("failed to update video") - errOpenFile error = errors.New("failed to open file") - errSetThumbnail error = errors.New("failed to set thumbnail") - errRating error = errors.New("failed to rate video") - errGetRating error = errors.New("failed to get rating") + errGetVideo = errors.New("failed to get video") + errInsertVideo = errors.New("failed to insert video") + errUpdateVideo = errors.New("failed to update video") + errOpenFile = errors.New("failed to open file") + errSetThumbnail = errors.New("failed to set thumbnail") + errRating = errors.New("failed to rate video") + errGetRating = errors.New("failed to get rating") ) type video struct { @@ -49,9 +49,9 @@ type Video interface { setThumbnail(string, *youtube.Service) } -type videoOption func(*video) +type VideoOption func(*video) -func NewVideo(opts ...videoOption) Video { +func NewVideo(opts ...VideoOption) Video { v := &video{} service = auth.NewY2BService() @@ -223,91 +223,91 @@ func (v *video) setThumbnail(thumbnail string, service *youtube.Service) { } } -func WithVideoId(id string) videoOption { +func WithVideoId(id string) VideoOption { return func(v *video) { v.id = id } } -func WithVideoFile(file string) videoOption { +func WithVideoFile(file string) VideoOption { return func(v *video) { v.file = file } } -func WithVideoTitle(title string) videoOption { +func WithVideoTitle(title string) VideoOption { return func(v *video) { v.title = title } } -func WithVideoDesc(desc string) videoOption { +func WithVideoDesc(desc string) VideoOption { return func(v *video) { v.desc = desc } } -func WithVideoTags(tags []string) videoOption { +func WithVideoTags(tags []string) VideoOption { return func(v *video) { v.tags = tags } } -func WithVideoLanguage(language string) videoOption { +func WithVideoLanguage(language string) VideoOption { return func(v *video) { v.language = language } } -func WithVideoThumbnail(thumbnail string) videoOption { +func WithVideoThumbnail(thumbnail string) VideoOption { return func(v *video) { v.thumbnail = thumbnail } } -func WithVideoRating(rating string) videoOption { +func WithVideoRating(rating string) VideoOption { return func(v *video) { v.rating = rating } } -func WithVideoChart(chart string) videoOption { +func WithVideoChart(chart string) VideoOption { return func(v *video) { v.chart = chart } } -func WithVideoForKids(forKids bool) videoOption { +func WithVideoForKids(forKids bool) VideoOption { return func(v *video) { v.forKids = forKids } } -func WithVideoEmbeddable(embeddable bool) videoOption { +func WithVideoEmbeddable(embeddable bool) VideoOption { return func(v *video) { v.embeddable = embeddable } } -func WithVideoCategory(category string) videoOption { +func WithVideoCategory(category string) VideoOption { return func(v *video) { v.category = category } } -func WithVideoPrivacy(privacy string) videoOption { +func WithVideoPrivacy(privacy string) VideoOption { return func(v *video) { v.privacy = privacy } } -func WithVideoChannelId(channelId string) videoOption { +func WithVideoChannelId(channelId string) VideoOption { return func(v *video) { v.channelId = channelId } } -func WithVideoPlaylistId(playlistId string) videoOption { +func WithVideoPlaylistId(playlistId string) VideoOption { return func(v *video) { v.playlistId = playlistId } diff --git a/pkg/yutuber/videoAbuseReportReason.go b/pkg/yutuber/videoAbuseReportReason.go index 6151b47..ae0eac2 100644 --- a/pkg/yutuber/videoAbuseReportReason.go +++ b/pkg/yutuber/videoAbuseReportReason.go @@ -10,7 +10,7 @@ import ( ) var ( - errGetVideoAbuseReportReason error = errors.New("failed to get video abuse report reason") + errGetVideoAbuseReportReason = errors.New("failed to get video abuse report reason") ) type videoAbuseReportReason struct{} @@ -20,9 +20,9 @@ type VideoAbuseReportReason interface { List([]string, string) } -type videoAbuseReportReasonOption func(*videoAbuseReportReason) +type VideoAbuseReportReasonOption func(*videoAbuseReportReason) -func NewVideoAbuseReportReason(opt ...videoAbuseReportReasonOption) VideoAbuseReportReason { +func NewVideoAbuseReportReason(opt ...VideoAbuseReportReasonOption) VideoAbuseReportReason { service = auth.NewY2BService() va := &videoAbuseReportReason{} for _, o := range opt { diff --git a/pkg/yutuber/videoCategory.go b/pkg/yutuber/videoCategory.go index 9694335..ce5b16c 100644 --- a/pkg/yutuber/videoCategory.go +++ b/pkg/yutuber/videoCategory.go @@ -11,7 +11,7 @@ import ( ) var ( - errGetVideoCategory error = errors.New("failed to get video category") + errGetVideoCategory = errors.New("failed to get video category") ) type videoCategory struct { @@ -23,9 +23,9 @@ type VideoCategory interface { List([]string, string) } -type videoCategoryOption func(*videoCategory) +type VideoCategoryOption func(*videoCategory) -func NewVideoCategory(opt ...videoCategoryOption) VideoCategory { +func NewVideoCategory(opt ...VideoCategoryOption) VideoCategory { service = auth.NewY2BService() vc := &videoCategory{} for _, o := range opt { @@ -62,7 +62,7 @@ func (vc *videoCategory) List(parts []string, output string) { } } -func WithRegionCode(regionCode string) videoCategoryOption { +func WithRegionCode(regionCode string) VideoCategoryOption { return func(vc *videoCategory) { vc.regionCode = regionCode }