It seems that the working code for receiving messages for a bot in a telegram on api, but how to properly implement the receipt of different messages (text, images, files), is obtained for each type of message a different structure.
package main import ( "encoding/json" "fmt" "io/ioutil" "log" "net/http" ) // TextMessage структура JSON полученных текстовых сообщений type TextMessage struct { Ok bool `json:"ok"` Result []struct { UpdateID int `json:"update_id"` Message struct { MessageID int `json:"message_id"` From struct { ID int `json:"id"` IsBot bool `json:"is_bot"` FirstName string `json:"first_name"` LastName string `json:"last_name"` LanguageCode string `json:"language_code"` } `json:"from"` Chat struct { ID int `json:"id"` FirstName string `json:"first_name"` LastName string `json:"last_name"` Type string `json:"type"` } `json:"chat"` Date int `json:"date"` Text string `json:"text"` } `json:"message"` } `json:"result"` } func main() { url := "https://api.telegram.org/botXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/getUpdates" getText, err := http.Get(url) if err != nil { log.Fatal(err) } defer getText.Body.Close() text, err := ioutil.ReadAll(getText.Body) if err != nil { log.Fatal(err) } bodyGet := []byte(text) var app = TextMessage{} err1 := json.Unmarshal(bodyGet, &app) if err1 != nil { log.Fatal("error") } for _, row := range app.Result { fmt.Printf("UpdateID:%d ChatID:%d Text:%s\n", row.UpdateID, row.Message.Chat.ID, row.Message.Text) } } File structure
type FileMessage struct { Ok bool `json:"ok"` Result []struct { UpdateID int `json:"update_id"` Message struct { MessageID int `json:"message_id"` From struct { ID int `json:"id"` IsBot bool `json:"is_bot"` FirstName string `json:"first_name"` LastName string `json:"last_name"` LanguageCode string `json:"language_code"` } `json:"from"` Chat struct { ID int `json:"id"` FirstName string `json:"first_name"` LastName string `json:"last_name"` Type string `json:"type"` } `json:"chat"` Date int `json:"date"` Document struct { FileName string `json:"file_name"` MimeType string `json:"mime_type"` Thumb struct { FileID string `json:"file_id"` FileSize int `json:"file_size"` Width int `json:"width"` Height int `json:"height"` } `json:"thumb"` FileID string `json:"file_id"` FileSize int `json:"file_size"` } `json:"document"` } `json:"message"` } `json:"result"` } Structure for the image
type ImgMessage struct { Ok bool `json:"ok"` Result []struct { UpdateID int `json:"update_id"` Message struct { MessageID int `json:"message_id"` From struct { ID int `json:"id"` IsBot bool `json:"is_bot"` FirstName string `json:"first_name"` LastName string `json:"last_name"` LanguageCode string `json:"language_code"` } `json:"from"` Chat struct { ID int `json:"id"` FirstName string `json:"first_name"` LastName string `json:"last_name"` Type string `json:"type"` } `json:"chat"` Date int `json:"date"` Photo []struct { FileID string `json:"file_id"` FileSize int `json:"file_size"` Width int `json:"width"` Height int `json:"height"` } `json:"photo"` } `json:"message"` } `json:"result"` }