No reason to use pointers to arrays.
Syfaro syfaro@huefox.com
Mon, 08 Oct 2018 23:32:34 -0500
4 files changed,
27 insertions(+),
27 deletions(-)
M
configs.go
→
configs.go
@@ -1070,13 +1070,13 @@
// InvoiceConfig contains information for sendInvoice request. type InvoiceConfig struct { BaseChat - Title string // required - Description string // required - Payload string // required - ProviderToken string // required - StartParameter string // required - Currency string // required - Prices *[]LabeledPrice // required + Title string // required + Description string // required + Payload string // required + ProviderToken string // required + StartParameter string // required + Currency string // required + Prices []LabeledPrice // required ProviderData string PhotoURL string PhotoSize int@@ -1132,7 +1132,7 @@ // ShippingConfig contains information for answerShippingQuery request.
type ShippingConfig struct { ShippingQueryID string // required OK bool // required - ShippingOptions *[]ShippingOption + ShippingOptions []ShippingOption ErrorMessage string }
M
helpers.go
→
helpers.go
@@ -737,7 +737,7 @@ }
} // NewInvoice creates a new Invoice request to the user. -func NewInvoice(chatID int64, title, description, payload, providerToken, startParameter, currency string, prices *[]LabeledPrice) InvoiceConfig { +func NewInvoice(chatID int64, title, description, payload, providerToken, startParameter, currency string, prices []LabeledPrice) InvoiceConfig { return InvoiceConfig{ BaseChat: BaseChat{ChatID: chatID}, Title: title,
M
types.go
→
types.go
@@ -147,13 +147,13 @@ EditDate int `json:"edit_date"` // optional
MediaGroupID string `json:"media_group_id"` // optional AuthorSignature string `json:"author_signature"` // optional Text string `json:"text"` // optional - Entities *[]MessageEntity `json:"entities"` // optional - CaptionEntities *[]MessageEntity `json:"caption_entities"` // optional + Entities []MessageEntity `json:"entities"` // optional + CaptionEntities []MessageEntity `json:"caption_entities"` // optional Audio *Audio `json:"audio"` // optional Document *Document `json:"document"` // optional Animation *ChatAnimation `json:"animation"` // optional Game *Game `json:"game"` // optional - Photo *[]PhotoSize `json:"photo"` // optional + Photo []PhotoSize `json:"photo"` // optional Sticker *Sticker `json:"sticker"` // optional Video *Video `json:"video"` // optional VideoNote *VideoNote `json:"video_note"` // optional@@ -162,10 +162,10 @@ Caption string `json:"caption"` // optional
Contact *Contact `json:"contact"` // optional Location *Location `json:"location"` // optional Venue *Venue `json:"venue"` // optional - NewChatMembers *[]User `json:"new_chat_members"` // optional + NewChatMembers []User `json:"new_chat_members"` // optional LeftChatMember *User `json:"left_chat_member"` // optional NewChatTitle string `json:"new_chat_title"` // optional - NewChatPhoto *[]PhotoSize `json:"new_chat_photo"` // optional + NewChatPhoto []PhotoSize `json:"new_chat_photo"` // optional DeleteChatPhoto bool `json:"delete_chat_photo"` // optional GroupChatCreated bool `json:"group_chat_created"` // optional SuperGroupChatCreated bool `json:"supergroup_chat_created"` // optional@@ -186,11 +186,11 @@ }
// IsCommand returns true if message starts with a "bot_command" entity. func (m *Message) IsCommand() bool { - if m.Entities == nil || len(*m.Entities) == 0 { + if m.Entities == nil || len(m.Entities) == 0 { return false } - entity := (*m.Entities)[0] + entity := m.Entities[0] return entity.Offset == 0 && entity.Type == "bot_command" }@@ -220,7 +220,7 @@ return ""
} // IsCommand() checks that the message begins with a bot_command entity - entity := (*m.Entities)[0] + entity := m.Entities[0] return m.Text[1:entity.Length] }@@ -239,7 +239,7 @@ return ""
} // IsCommand() checks that the message begins with a bot_command entity - entity := (*m.Entities)[0] + entity := m.Entities[0] if len(m.Text) == entity.Length { return "" // The command makes up the whole message@@ -795,9 +795,9 @@ }
// ShippingOption represents one shipping option. type ShippingOption struct { - ID string `json:"id"` - Title string `json:"title"` - Prices *[]LabeledPrice `json:"prices"` + ID string `json:"id"` + Title string `json:"title"` + Prices []LabeledPrice `json:"prices"` } // SuccessfulPayment contains basic information about a successful payment.
M
types_test.go
→
types_test.go
@@ -47,7 +47,7 @@ }
func TestMessageIsCommandWithCommand(t *testing.T) { message := tgbotapi.Message{Text: "/command"} - message.Entities = &[]tgbotapi.MessageEntity{{Type: "bot_command", Offset: 0, Length: 8}} + message.Entities = []tgbotapi.MessageEntity{{Type: "bot_command", Offset: 0, Length: 8}} if !message.IsCommand() { t.Fail()@@ -72,7 +72,7 @@ }
func TestCommandWithCommand(t *testing.T) { message := tgbotapi.Message{Text: "/command"} - message.Entities = &[]tgbotapi.MessageEntity{{Type: "bot_command", Offset: 0, Length: 8}} + message.Entities = []tgbotapi.MessageEntity{{Type: "bot_command", Offset: 0, Length: 8}} if message.Command() != "command" { t.Fail()@@ -97,7 +97,7 @@ }
func TestCommandWithBotName(t *testing.T) { message := tgbotapi.Message{Text: "/command@testbot"} - message.Entities = &[]tgbotapi.MessageEntity{{Type: "bot_command", Offset: 0, Length: 16}} + message.Entities = []tgbotapi.MessageEntity{{Type: "bot_command", Offset: 0, Length: 16}} if message.Command() != "command" { t.Fail()@@ -106,7 +106,7 @@ }
func TestCommandWithAtWithBotName(t *testing.T) { message := tgbotapi.Message{Text: "/command@testbot"} - message.Entities = &[]tgbotapi.MessageEntity{{Type: "bot_command", Offset: 0, Length: 16}} + message.Entities = []tgbotapi.MessageEntity{{Type: "bot_command", Offset: 0, Length: 16}} if message.CommandWithAt() != "command@testbot" { t.Fail()@@ -115,7 +115,7 @@ }
func TestMessageCommandArgumentsWithArguments(t *testing.T) { message := tgbotapi.Message{Text: "/command with arguments"} - message.Entities = &[]tgbotapi.MessageEntity{{Type: "bot_command", Offset: 0, Length: 8}} + message.Entities = []tgbotapi.MessageEntity{{Type: "bot_command", Offset: 0, Length: 8}} if message.CommandArguments() != "with arguments" { t.Fail() }@@ -123,7 +123,7 @@ }
func TestMessageCommandArgumentsWithMalformedArguments(t *testing.T) { message := tgbotapi.Message{Text: "/command-without argument space"} - message.Entities = &[]tgbotapi.MessageEntity{{Type: "bot_command", Offset: 0, Length: 8}} + message.Entities = []tgbotapi.MessageEntity{{Type: "bot_command", Offset: 0, Length: 8}} if message.CommandArguments() != "without argument space" { t.Fail() }