@ -1,4 +1,4 @@
package main
package tgbotapi
import (
"bytes"
@ -25,23 +25,98 @@ const (
CHAT_FIND_LOCATION = "find_location"
)
type BotConfig struct {
token string
debug bool
type MessageConfig struct {
ChatId int
Text string
DisableWebPagePreview bool
ReplyToMessageId int
ReplyMarkup interface { }
}
type BotApi struct {
config BotConfig
type ForwardConfig struct {
ChatId int
FromChatId int
MessageId int
}
func NewBotApi ( config BotConfig ) * BotApi {
return & BotApi {
config : config ,
}
type PhotoConfig struct {
ChatId int
Caption string
ReplyToMessageId int
ReplyMarkup interface { }
UseExistingPhoto bool
FilePath string
FileId string
}
type AudioConfig struct {
ChatId int
ReplyToMessageId int
ReplyMarkup interface { }
UseExistingAudio bool
FilePath string
FileId string
}
type DocumentConfig struct {
ChatId int
ReplyToMessageId int
ReplyMarkup interface { }
UseExistingDocument bool
FilePath string
FileId string
}
type StickerConfig struct {
ChatId int
ReplyToMessageId int
ReplyMarkup interface { }
UseExistingSticker bool
FilePath string
FileId string
}
type VideoConfig struct {
ChatId int
ReplyToMessageId int
ReplyMarkup interface { }
UseExistingVideo bool
FilePath string
FileId string
}
type LocationConfig struct {
ChatId int
Latitude float64
Longitude float64
ReplyToMessageId int
ReplyMarkup interface { }
}
type ChatActionConfig struct {
ChatId int
Action string
}
type UserProfilePhotosConfig struct {
UserId int
Offset int
Limit int
}
type UpdateConfig struct {
Offset int
Limit int
Timeout int
}
type WebhookConfig struct {
Clear bool
Url * url . URL
}
func ( bot * BotApi ) makeRequest ( endpoint string , params url . Values ) ( ApiResponse , error ) {
resp , err := http . PostForm ( "https://api.telegram.org/bot" + bot . config . token + "/" + endpoint , params )
func ( bot * BotApi ) M akeRequest( endpoint string , params url . Values ) ( ApiResponse , error ) {
resp , err := http . PostForm ( "https://api.telegram.org/bot" + bot . T oken+ "/" + endpoint , params )
defer resp . Body . Close ( )
if err != nil {
return ApiResponse { } , err
@ -52,7 +127,7 @@ func (bot *BotApi) makeRequest(endpoint string, params url.Values) (ApiResponse,
return ApiResponse { } , err
}
if bot . config . d ebug {
if bot . D ebug {
log . Println ( endpoint , string ( bytes ) )
}
@ -66,7 +141,7 @@ func (bot *BotApi) makeRequest(endpoint string, params url.Values) (ApiResponse,
return apiResp , nil
}
func ( bot * BotApi ) u ploadFile( endpoint string , params map [ string ] string , fieldname string , filename string ) ( ApiResponse , error ) {
func ( bot * BotApi ) U ploadFile( endpoint string , params map [ string ] string , fieldname string , filename string ) ( ApiResponse , error ) {
var b bytes . Buffer
w := multipart . NewWriter ( & b )
@ -96,7 +171,7 @@ func (bot *BotApi) uploadFile(endpoint string, params map[string]string, fieldna
w . Close ( )
req , err := http . NewRequest ( "POST" , "https://api.telegram.org/bot" + bot . config . t oken+ "/" + endpoint , & b )
req , err := http . NewRequest ( "POST" , "https://api.telegram.org/bot" + bot . T oken+ "/" + endpoint , & b )
if err != nil {
return ApiResponse { } , err
}
@ -114,7 +189,7 @@ func (bot *BotApi) uploadFile(endpoint string, params map[string]string, fieldna
return ApiResponse { } , err
}
if bot . config . d ebug {
if bot . D ebug {
log . Println ( string ( bytes [ : ] ) )
}
@ -124,8 +199,8 @@ func (bot *BotApi) uploadFile(endpoint string, params map[string]string, fieldna
return apiResp , nil
}
func ( bot * BotApi ) g etMe( ) ( User , error ) {
resp , err := bot . m akeRequest( "getMe" , nil )
func ( bot * BotApi ) G etMe( ) ( User , error ) {
resp , err := bot . M akeRequest( "getMe" , nil )
if err != nil {
return User { } , err
}
@ -133,14 +208,14 @@ func (bot *BotApi) getMe() (User, error) {
var user User
json . Unmarshal ( resp . Result , & user )
if bot . config . d ebug {
if bot . D ebug {
log . Printf ( "getMe: %+v\n" , user )
}
return user , nil
}
func ( bot * BotApi ) s endMessage( config MessageConfig ) ( Message , error ) {
func ( bot * BotApi ) S endMessage( config MessageConfig ) ( Message , error ) {
v := url . Values { }
v . Add ( "chat_id" , strconv . Itoa ( config . ChatId ) )
v . Add ( "text" , config . Text )
@ -157,7 +232,7 @@ func (bot *BotApi) sendMessage(config MessageConfig) (Message, error) {
v . Add ( "reply_markup" , string ( data ) )
}
resp , err := bot . makeRequest ( "s endMessage", v )
resp , err := bot . MakeRequest ( "S endMessage", v )
if err != nil {
return Message { } , err
}
@ -165,21 +240,21 @@ func (bot *BotApi) sendMessage(config MessageConfig) (Message, error) {
var message Message
json . Unmarshal ( resp . Result , & message )
if bot . config . d ebug {
log . Printf ( "s endMessage req : %+v\n" , v )
log . Printf ( "s endMessage resp: %+v\n" , message )
if bot . D ebug {
log . Printf ( "S endMessage req : %+v\n" , v )
log . Printf ( "S endMessage resp: %+v\n" , message )
}
return message , nil
}
func ( bot * BotApi ) f orwardMessage( config ForwardConfig ) ( Message , error ) {
func ( bot * BotApi ) F orwardMessage( config ForwardConfig ) ( Message , error ) {
v := url . Values { }
v . Add ( "chat_id" , strconv . Itoa ( config . ChatId ) )
v . Add ( "from_chat_id" , strconv . Itoa ( config . FromChatId ) )
v . Add ( "message_id" , strconv . Itoa ( config . MessageId ) )
resp , err := bot . m akeRequest( "forwardMessage" , v )
resp , err := bot . M akeRequest( "forwardMessage" , v )
if err != nil {
return Message { } , err
}
@ -187,7 +262,7 @@ func (bot *BotApi) forwardMessage(config ForwardConfig) (Message, error) {
var message Message
json . Unmarshal ( resp . Result , & message )
if bot . config . d ebug {
if bot . D ebug {
log . Printf ( "forwardMessage req : %+v\n" , v )
log . Printf ( "forwardMessage resp: %+v\n" , message )
}
@ -195,7 +270,7 @@ func (bot *BotApi) forwardMessage(config ForwardConfig) (Message, error) {
return message , nil
}
func ( bot * BotApi ) s endPhoto( config PhotoConfig ) ( Message , error ) {
func ( bot * BotApi ) S endPhoto( config PhotoConfig ) ( Message , error ) {
if config . UseExistingPhoto {
v := url . Values { }
v . Add ( "chat_id" , strconv . Itoa ( config . ChatId ) )
@ -215,7 +290,7 @@ func (bot *BotApi) sendPhoto(config PhotoConfig) (Message, error) {
v . Add ( "reply_markup" , string ( data ) )
}
resp , err := bot . makeRequest ( "s endPhoto", v )
resp , err := bot . MakeRequest ( "S endPhoto", v )
if err != nil {
return Message { } , err
}
@ -223,9 +298,9 @@ func (bot *BotApi) sendPhoto(config PhotoConfig) (Message, error) {
var message Message
json . Unmarshal ( resp . Result , & message )
if bot . config . d ebug {
log . Printf ( "s endPhoto req : %+v\n" , v )
log . Printf ( "s endPhoto resp: %+v\n" , message )
if bot . D ebug {
log . Printf ( "S endPhoto req : %+v\n" , v )
log . Printf ( "S endPhoto resp: %+v\n" , message )
}
return message , nil
@ -248,7 +323,7 @@ func (bot *BotApi) sendPhoto(config PhotoConfig) (Message, error) {
params [ "reply_markup" ] = string ( data )
}
resp , err := bot . uploadFile ( "s endPhoto", params , "photo" , config . FilePath )
resp , err := bot . UploadFile ( "S endPhoto", params , "photo" , config . FilePath )
if err != nil {
return Message { } , err
}
@ -256,14 +331,14 @@ func (bot *BotApi) sendPhoto(config PhotoConfig) (Message, error) {
var message Message
json . Unmarshal ( resp . Result , & message )
if bot . config . d ebug {
log . Printf ( "s endPhoto resp: %+v\n" , message )
if bot . D ebug {
log . Printf ( "S endPhoto resp: %+v\n" , message )
}
return message , nil
}
func ( bot * BotApi ) s endAudio( config AudioConfig ) ( Message , error ) {
func ( bot * BotApi ) S endAudio( config AudioConfig ) ( Message , error ) {
if config . UseExistingAudio {
v := url . Values { }
v . Add ( "chat_id" , strconv . Itoa ( config . ChatId ) )
@ -280,7 +355,7 @@ func (bot *BotApi) sendAudio(config AudioConfig) (Message, error) {
v . Add ( "reply_markup" , string ( data ) )
}
resp , err := bot . m akeRequest( "sendAudio" , v )
resp , err := bot . M akeRequest( "sendAudio" , v )
if err != nil {
return Message { } , err
}
@ -288,7 +363,7 @@ func (bot *BotApi) sendAudio(config AudioConfig) (Message, error) {
var message Message
json . Unmarshal ( resp . Result , & message )
if bot . config . d ebug {
if bot . D ebug {
log . Printf ( "sendAudio req : %+v\n" , v )
log . Printf ( "sendAudio resp: %+v\n" , message )
}
@ -311,7 +386,7 @@ func (bot *BotApi) sendAudio(config AudioConfig) (Message, error) {
params [ "reply_markup" ] = string ( data )
}
resp , err := bot . u ploadFile( "sendAudio" , params , "audio" , config . FilePath )
resp , err := bot . U ploadFile( "sendAudio" , params , "audio" , config . FilePath )
if err != nil {
return Message { } , err
}
@ -319,14 +394,14 @@ func (bot *BotApi) sendAudio(config AudioConfig) (Message, error) {
var message Message
json . Unmarshal ( resp . Result , & message )
if bot . config . d ebug {
if bot . D ebug {
log . Printf ( "sendAudio resp: %+v\n" , message )
}
return message , nil
}
func ( bot * BotApi ) s endDocument( config DocumentConfig ) ( Message , error ) {
func ( bot * BotApi ) S endDocument( config DocumentConfig ) ( Message , error ) {
if config . UseExistingDocument {
v := url . Values { }
v . Add ( "chat_id" , strconv . Itoa ( config . ChatId ) )
@ -343,7 +418,7 @@ func (bot *BotApi) sendDocument(config DocumentConfig) (Message, error) {
v . Add ( "reply_markup" , string ( data ) )
}
resp , err := bot . m akeRequest( "sendDocument" , v )
resp , err := bot . M akeRequest( "sendDocument" , v )
if err != nil {
return Message { } , err
}
@ -351,7 +426,7 @@ func (bot *BotApi) sendDocument(config DocumentConfig) (Message, error) {
var message Message
json . Unmarshal ( resp . Result , & message )
if bot . config . d ebug {
if bot . D ebug {
log . Printf ( "sendDocument req : %+v\n" , v )
log . Printf ( "sendDocument resp: %+v\n" , message )
}
@ -374,7 +449,7 @@ func (bot *BotApi) sendDocument(config DocumentConfig) (Message, error) {
params [ "reply_markup" ] = string ( data )
}
resp , err := bot . u ploadFile( "sendDocument" , params , "document" , config . FilePath )
resp , err := bot . U ploadFile( "sendDocument" , params , "document" , config . FilePath )
if err != nil {
return Message { } , err
}
@ -382,14 +457,14 @@ func (bot *BotApi) sendDocument(config DocumentConfig) (Message, error) {
var message Message
json . Unmarshal ( resp . Result , & message )
if bot . config . d ebug {
if bot . D ebug {
log . Printf ( "sendDocument resp: %+v\n" , message )
}
return message , nil
}
func ( bot * BotApi ) s endSticker( config StickerConfig ) ( Message , error ) {
func ( bot * BotApi ) S endSticker( config StickerConfig ) ( Message , error ) {
if config . UseExistingSticker {
v := url . Values { }
v . Add ( "chat_id" , strconv . Itoa ( config . ChatId ) )
@ -406,7 +481,7 @@ func (bot *BotApi) sendSticker(config StickerConfig) (Message, error) {
v . Add ( "reply_markup" , string ( data ) )
}
resp , err := bot . m akeRequest( "sendSticker" , v )
resp , err := bot . M akeRequest( "sendSticker" , v )
if err != nil {
return Message { } , err
}
@ -414,7 +489,7 @@ func (bot *BotApi) sendSticker(config StickerConfig) (Message, error) {
var message Message
json . Unmarshal ( resp . Result , & message )
if bot . config . d ebug {
if bot . D ebug {
log . Printf ( "sendSticker req : %+v\n" , v )
log . Printf ( "sendSticker resp: %+v\n" , message )
}
@ -437,7 +512,7 @@ func (bot *BotApi) sendSticker(config StickerConfig) (Message, error) {
params [ "reply_markup" ] = string ( data )
}
resp , err := bot . u ploadFile( "sendSticker" , params , "sticker" , config . FilePath )
resp , err := bot . U ploadFile( "sendSticker" , params , "sticker" , config . FilePath )
if err != nil {
return Message { } , err
}
@ -445,14 +520,14 @@ func (bot *BotApi) sendSticker(config StickerConfig) (Message, error) {
var message Message
json . Unmarshal ( resp . Result , & message )
if bot . config . d ebug {
if bot . D ebug {
log . Printf ( "sendSticker resp: %+v\n" , message )
}
return message , nil
}
func ( bot * BotApi ) s endVideo( config VideoConfig ) ( Message , error ) {
func ( bot * BotApi ) S endVideo( config VideoConfig ) ( Message , error ) {
if config . UseExistingVideo {
v := url . Values { }
v . Add ( "chat_id" , strconv . Itoa ( config . ChatId ) )
@ -469,7 +544,7 @@ func (bot *BotApi) sendVideo(config VideoConfig) (Message, error) {
v . Add ( "reply_markup" , string ( data ) )
}
resp , err := bot . m akeRequest( "sendVideo" , v )
resp , err := bot . M akeRequest( "sendVideo" , v )
if err != nil {
return Message { } , err
}
@ -477,7 +552,7 @@ func (bot *BotApi) sendVideo(config VideoConfig) (Message, error) {
var message Message
json . Unmarshal ( resp . Result , & message )
if bot . config . d ebug {
if bot . D ebug {
log . Printf ( "sendVideo req : %+v\n" , v )
log . Printf ( "sendVideo resp: %+v\n" , message )
}
@ -500,7 +575,7 @@ func (bot *BotApi) sendVideo(config VideoConfig) (Message, error) {
params [ "reply_markup" ] = string ( data )
}
resp , err := bot . u ploadFile( "sendVideo" , params , "video" , config . FilePath )
resp , err := bot . U ploadFile( "sendVideo" , params , "video" , config . FilePath )
if err != nil {
return Message { } , err
}
@ -508,14 +583,14 @@ func (bot *BotApi) sendVideo(config VideoConfig) (Message, error) {
var message Message
json . Unmarshal ( resp . Result , & message )
if bot . config . d ebug {
if bot . D ebug {
log . Printf ( "sendVideo resp: %+v\n" , message )
}
return message , nil
}
func ( bot * BotApi ) s endLocation( config LocationConfig ) ( Message , error ) {
func ( bot * BotApi ) S endLocation( config LocationConfig ) ( Message , error ) {
v := url . Values { }
v . Add ( "chat_id" , strconv . Itoa ( config . ChatId ) )
v . Add ( "latitude" , strconv . FormatFloat ( config . Latitude , 'f' , 6 , 64 ) )
@ -532,7 +607,7 @@ func (bot *BotApi) sendLocation(config LocationConfig) (Message, error) {
v . Add ( "reply_markup" , string ( data ) )
}
resp , err := bot . m akeRequest( "sendLocation" , v )
resp , err := bot . M akeRequest( "sendLocation" , v )
if err != nil {
return Message { } , err
}
@ -540,7 +615,7 @@ func (bot *BotApi) sendLocation(config LocationConfig) (Message, error) {
var message Message
json . Unmarshal ( resp . Result , & message )
if bot . config . d ebug {
if bot . D ebug {
log . Printf ( "sendLocation req : %+v\n" , v )
log . Printf ( "sendLocation resp: %+v\n" , message )
}
@ -548,12 +623,12 @@ func (bot *BotApi) sendLocation(config LocationConfig) (Message, error) {
return message , nil
}
func ( bot * BotApi ) s endChatAction( config ChatActionConfig ) error {
func ( bot * BotApi ) S endChatAction( config ChatActionConfig ) error {
v := url . Values { }
v . Add ( "chat_id" , strconv . Itoa ( config . ChatId ) )
v . Add ( "action" , config . Action )
_ , err := bot . m akeRequest( "sendChatAction" , v )
_ , err := bot . M akeRequest( "sendChatAction" , v )
if err != nil {
return err
}
@ -561,7 +636,7 @@ func (bot *BotApi) sendChatAction(config ChatActionConfig) error {
return nil
}
func ( bot * BotApi ) g etUserProfilePhotos( config UserProfilePhotosConfig ) ( UserProfilePhotos , error ) {
func ( bot * BotApi ) G etUserProfilePhotos( config UserProfilePhotosConfig ) ( UserProfilePhotos , error ) {
v := url . Values { }
v . Add ( "user_id" , strconv . Itoa ( config . UserId ) )
if config . Offset != 0 {
@ -571,7 +646,7 @@ func (bot *BotApi) getUserProfilePhotos(config UserProfilePhotosConfig) (UserPro
v . Add ( "limit" , strconv . Itoa ( config . Limit ) )
}
resp , err := bot . m akeRequest( "getUserProfilePhotos" , v )
resp , err := bot . M akeRequest( "getUserProfilePhotos" , v )
if err != nil {
return UserProfilePhotos { } , err
}
@ -579,7 +654,7 @@ func (bot *BotApi) getUserProfilePhotos(config UserProfilePhotosConfig) (UserPro
var profilePhotos UserProfilePhotos
json . Unmarshal ( resp . Result , & profilePhotos )
if bot . config . d ebug {
if bot . D ebug {
log . Printf ( "getUserProfilePhotos req : %+v\n" , v )
log . Printf ( "getUserProfilePhotos resp: %+v\n" , profilePhotos )
}
@ -587,7 +662,7 @@ func (bot *BotApi) getUserProfilePhotos(config UserProfilePhotosConfig) (UserPro
return profilePhotos , nil
}
func ( bot * BotApi ) g etUpdates( config UpdateConfig ) ( [ ] Update , error ) {
func ( bot * BotApi ) G etUpdates( config UpdateConfig ) ( [ ] Update , error ) {
v := url . Values { }
if config . Offset > 0 {
v . Add ( "offset" , strconv . Itoa ( config . Offset ) )
@ -599,7 +674,7 @@ func (bot *BotApi) getUpdates(config UpdateConfig) ([]Update, error) {
v . Add ( "timeout" , strconv . Itoa ( config . Timeout ) )
}
resp , err := bot . m akeRequest( "getUpdates" , v )
resp , err := bot . M akeRequest( "getUpdates" , v )
if err != nil {
return [ ] Update { } , err
}
@ -607,230 +682,20 @@ func (bot *BotApi) getUpdates(config UpdateConfig) ([]Update, error) {
var updates [ ] Update
json . Unmarshal ( resp . Result , & updates )
if bot . config . d ebug {
if bot . D ebug {
log . Printf ( "getUpdates: %+v\n" , updates )
}
return updates , nil
}
func ( bot * BotApi ) setWebhook ( v url . Values ) error {
_ , err := bot . makeRequest ( "setWebhook" , v )
return err
}
type UpdateConfig struct {
Offset int
Limit int
Timeout int
}
type MessageConfig struct {
ChatId int
Text string
DisableWebPagePreview bool
ReplyToMessageId int
ReplyMarkup interface { }
}
type ForwardConfig struct {
ChatId int
FromChatId int
MessageId int
}
type PhotoConfig struct {
ChatId int
Caption string
ReplyToMessageId int
ReplyMarkup interface { }
UseExistingPhoto bool
FilePath string
FileId string
}
type AudioConfig struct {
ChatId int
ReplyToMessageId int
ReplyMarkup interface { }
UseExistingAudio bool
FilePath string
FileId string
}
type DocumentConfig struct {
ChatId int
ReplyToMessageId int
ReplyMarkup interface { }
UseExistingDocument bool
FilePath string
FileId string
}
type StickerConfig struct {
ChatId int
ReplyToMessageId int
ReplyMarkup interface { }
UseExistingSticker bool
FilePath string
FileId string
}
type VideoConfig struct {
ChatId int
ReplyToMessageId int
ReplyMarkup interface { }
UseExistingVideo bool
FilePath string
FileId string
}
type LocationConfig struct {
ChatId int
Latitude float64
Longitude float64
ReplyToMessageId int
ReplyMarkup interface { }
}
type ChatActionConfig struct {
ChatId int
Action string
}
type UserProfilePhotosConfig struct {
UserId int
Offset int
Limit int
}
func NewMessage ( chatId int , text string ) MessageConfig {
return MessageConfig {
ChatId : chatId ,
Text : text ,
DisableWebPagePreview : false ,
ReplyToMessageId : 0 ,
}
}
func NewForward ( chatId int , fromChatId int , messageId int ) ForwardConfig {
return ForwardConfig {
ChatId : chatId ,
FromChatId : fromChatId ,
MessageId : messageId ,
}
}
func NewPhotoUpload ( chatId int , filename string ) PhotoConfig {
return PhotoConfig {
ChatId : chatId ,
UseExistingPhoto : false ,
FilePath : filename ,
}
}
func NewPhotoShare ( chatId int , fileId string ) PhotoConfig {
return PhotoConfig {
ChatId : chatId ,
UseExistingPhoto : true ,
FileId : fileId ,
}
}
func NewAudioUpload ( chatId int , filename string ) AudioConfig {
return AudioConfig {
ChatId : chatId ,
UseExistingAudio : false ,
FilePath : filename ,
}
}
func NewAudioShare ( chatId int , fileId string ) AudioConfig {
return AudioConfig {
ChatId : chatId ,
UseExistingAudio : true ,
FileId : fileId ,
}
}
func NewDocumentUpload ( chatId int , filename string ) DocumentConfig {
return DocumentConfig {
ChatId : chatId ,
UseExistingDocument : false ,
FilePath : filename ,
}
}
func NewDocumentShare ( chatId int , fileId string ) DocumentConfig {
return DocumentConfig {
ChatId : chatId ,
UseExistingDocument : true ,
FileId : fileId ,
}
}
func NewStickerUpload ( chatId int , filename string ) StickerConfig {
return StickerConfig {
ChatId : chatId ,
UseExistingSticker : false ,
FilePath : filename ,
}
}
func NewStickerShare ( chatId int , fileId string ) StickerConfig {
return StickerConfig {
ChatId : chatId ,
UseExistingSticker : true ,
FileId : fileId ,
}
}
func NewVideoUpload ( chatId int , filename string ) VideoConfig {
return VideoConfig {
ChatId : chatId ,
UseExistingVideo : false ,
FilePath : filename ,
}
}
func NewVideoShare ( chatId int , fileId string ) VideoConfig {
return VideoConfig {
ChatId : chatId ,
UseExistingVideo : true ,
FileId : fileId ,
}
}
func NewLocation ( chatId int , latitude float64 , longitude float64 ) LocationConfig {
return LocationConfig {
ChatId : chatId ,
Latitude : latitude ,
Longitude : longitude ,
ReplyToMessageId : 0 ,
ReplyMarkup : nil ,
}
}
func NewChatAction ( chatId int , action string ) ChatActionConfig {
return ChatActionConfig {
ChatId : chatId ,
Action : action ,
func ( bot * BotApi ) SetWebhook ( config WebhookConfig ) error {
v := url . Values { }
if ! config . Clear {
v . Add ( "url" , config . Url . String ( ) )
}
}
func NewUserProfilePhotos ( userId int ) UserProfilePhotosConfig {
return UserProfilePhotosConfig {
UserId : userId ,
Offset : 0 ,
Limit : 0 ,
}
}
_ , err := bot . MakeRequest ( "setWebhook" , v )
func NewUpdate ( offset int ) UpdateConfig {
return UpdateConfig {
Offset : offset ,
Limit : 0 ,
Timeout : 0 ,
}
return err
}