♻️ Export return type of exported func

This commit is contained in:
chaoqun committed 2024-05-05 21:51:13 +08:00
1 parent f4822cd287
commit be120ccde9
12 files changed
+79 -79

No files matched your search

+4 -4
View File
@@ -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
}
+8 -8
View File
@@ -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
}
+2 -2
View File
@@ -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{}
+2 -2
View File
@@ -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{}
+4 -4
View File
@@ -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
}
+3 -3
View File
@@ -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()
+12 -12
View File
@@ -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
}
+12 -12
View File
@@ -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
}
+1 -1
View File
@@ -10,7 +10,7 @@ import (
)
var (
errGetSearch error = errors.New("failed to get search")
errGetSearch = errors.New("failed to get search")
)
type search struct {
+24 -24
View File
@@ -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
}
+3 -3
View File
@@ -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 {
+4 -4
View File
@@ -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
}