Best Go-testdeep code snippet using td.unmarshal
richText.go
Source:richText.go  
...29	RichTextAnchorType        RichTextEnum = "richTextAnchor"30	RichTextAnchorLinkType    RichTextEnum = "richTextAnchorLink"31	RichTextsType             RichTextEnum = "richTexts"32)33func unmarshalRichText(rawMsg *json.RawMessage) (RichText, error) {34	if rawMsg == nil {35		return nil, nil36	}37	var objMap map[string]interface{}38	err := json.Unmarshal(*rawMsg, &objMap)39	if err != nil {40		return nil, err41	}42	switch RichTextEnum(objMap["@type"].(string)) {43	case RichTextPlainType:44		var richTextPlain RichTextPlain45		err := json.Unmarshal(*rawMsg, &richTextPlain)46		return &richTextPlain, err47	case RichTextBoldType:48		var richTextBold RichTextBold49		err := json.Unmarshal(*rawMsg, &richTextBold)50		return &richTextBold, err51	case RichTextItalicType:52		var richTextItalic RichTextItalic53		err := json.Unmarshal(*rawMsg, &richTextItalic)54		return &richTextItalic, err55	case RichTextUnderlineType:56		var richTextUnderline RichTextUnderline57		err := json.Unmarshal(*rawMsg, &richTextUnderline)58		return &richTextUnderline, err59	case RichTextStrikethroughType:60		var richTextStrikethrough RichTextStrikethrough61		err := json.Unmarshal(*rawMsg, &richTextStrikethrough)62		return &richTextStrikethrough, err63	case RichTextFixedType:64		var richTextFixed RichTextFixed65		err := json.Unmarshal(*rawMsg, &richTextFixed)66		return &richTextFixed, err67	case RichTextURLType:68		var richTextURL RichTextURL69		err := json.Unmarshal(*rawMsg, &richTextURL)70		return &richTextURL, err71	case RichTextEmailAddressType:72		var richTextEmailAddress RichTextEmailAddress73		err := json.Unmarshal(*rawMsg, &richTextEmailAddress)74		return &richTextEmailAddress, err75	case RichTextSubscriptType:76		var richTextSubscript RichTextSubscript77		err := json.Unmarshal(*rawMsg, &richTextSubscript)78		return &richTextSubscript, err79	case RichTextSuperscriptType:80		var richTextSuperscript RichTextSuperscript81		err := json.Unmarshal(*rawMsg, &richTextSuperscript)82		return &richTextSuperscript, err83	case RichTextMarkedType:84		var richTextMarked RichTextMarked85		err := json.Unmarshal(*rawMsg, &richTextMarked)86		return &richTextMarked, err87	case RichTextPhoneNumberType:88		var richTextPhoneNumber RichTextPhoneNumber89		err := json.Unmarshal(*rawMsg, &richTextPhoneNumber)90		return &richTextPhoneNumber, err91	case RichTextIconType:92		var richTextIcon RichTextIcon93		err := json.Unmarshal(*rawMsg, &richTextIcon)94		return &richTextIcon, err95	case RichTextReferenceType:96		var richTextReference RichTextReference97		err := json.Unmarshal(*rawMsg, &richTextReference)98		return &richTextReference, err99	case RichTextAnchorType:100		var richTextAnchor RichTextAnchor101		err := json.Unmarshal(*rawMsg, &richTextAnchor)102		return &richTextAnchor, err103	case RichTextAnchorLinkType:104		var richTextAnchorLink RichTextAnchorLink105		err := json.Unmarshal(*rawMsg, &richTextAnchorLink)106		return &richTextAnchorLink, err107	case RichTextsType:108		var richTexts RichTexts109		err := json.Unmarshal(*rawMsg, &richTexts)110		return &richTexts, err111	default:112		return nil, fmt.Errorf("Error UnMarshaling, unknown type:" + objMap["@type"].(string))113	}114}115// RichTextPlain A plain text116type RichTextPlain struct {117	tdCommon118	Text string `json:"text"` // Text119}120// MessageType return the string telegram-type of RichTextPlain121func (richTextPlain *RichTextPlain) MessageType() string {122	return "richTextPlain"123}124// NewRichTextPlain creates a new RichTextPlain125//126// @param text Text127func NewRichTextPlain(text string) *RichTextPlain {128	richTextPlainTemp := RichTextPlain{129		tdCommon: tdCommon{Type: "richTextPlain"},130		Text:     text,131	}132	return &richTextPlainTemp133}134// GetRichTextEnum return the enum type of this object135func (richTextPlain *RichTextPlain) GetRichTextEnum() RichTextEnum {136	return RichTextPlainType137}138// RichTextBold A bold rich text139type RichTextBold struct {140	tdCommon141	Text RichText `json:"text"` // Text142}143// MessageType return the string telegram-type of RichTextBold144func (richTextBold *RichTextBold) MessageType() string {145	return "richTextBold"146}147// NewRichTextBold creates a new RichTextBold148//149// @param text Text150func NewRichTextBold(text RichText) *RichTextBold {151	richTextBoldTemp := RichTextBold{152		tdCommon: tdCommon{Type: "richTextBold"},153		Text:     text,154	}155	return &richTextBoldTemp156}157// UnmarshalJSON unmarshal to json158func (richTextBold *RichTextBold) UnmarshalJSON(b []byte) error {159	var objMap map[string]*json.RawMessage160	err := json.Unmarshal(b, &objMap)161	if err != nil {162		return err163	}164	tempObj := struct {165		tdCommon166	}{}167	err = json.Unmarshal(b, &tempObj)168	if err != nil {169		return err170	}171	richTextBold.tdCommon = tempObj.tdCommon172	fieldText, _ := unmarshalRichText(objMap["text"])173	richTextBold.Text = fieldText174	return nil175}176// GetRichTextEnum return the enum type of this object177func (richTextBold *RichTextBold) GetRichTextEnum() RichTextEnum {178	return RichTextBoldType179}180// RichTextItalic An italicized rich text181type RichTextItalic struct {182	tdCommon183	Text RichText `json:"text"` // Text184}185// MessageType return the string telegram-type of RichTextItalic186func (richTextItalic *RichTextItalic) MessageType() string {187	return "richTextItalic"188}189// NewRichTextItalic creates a new RichTextItalic190//191// @param text Text192func NewRichTextItalic(text RichText) *RichTextItalic {193	richTextItalicTemp := RichTextItalic{194		tdCommon: tdCommon{Type: "richTextItalic"},195		Text:     text,196	}197	return &richTextItalicTemp198}199// UnmarshalJSON unmarshal to json200func (richTextItalic *RichTextItalic) UnmarshalJSON(b []byte) error {201	var objMap map[string]*json.RawMessage202	err := json.Unmarshal(b, &objMap)203	if err != nil {204		return err205	}206	tempObj := struct {207		tdCommon208	}{}209	err = json.Unmarshal(b, &tempObj)210	if err != nil {211		return err212	}213	richTextItalic.tdCommon = tempObj.tdCommon214	fieldText, _ := unmarshalRichText(objMap["text"])215	richTextItalic.Text = fieldText216	return nil217}218// GetRichTextEnum return the enum type of this object219func (richTextItalic *RichTextItalic) GetRichTextEnum() RichTextEnum {220	return RichTextItalicType221}222// RichTextUnderline An underlined rich text223type RichTextUnderline struct {224	tdCommon225	Text RichText `json:"text"` // Text226}227// MessageType return the string telegram-type of RichTextUnderline228func (richTextUnderline *RichTextUnderline) MessageType() string {229	return "richTextUnderline"230}231// NewRichTextUnderline creates a new RichTextUnderline232//233// @param text Text234func NewRichTextUnderline(text RichText) *RichTextUnderline {235	richTextUnderlineTemp := RichTextUnderline{236		tdCommon: tdCommon{Type: "richTextUnderline"},237		Text:     text,238	}239	return &richTextUnderlineTemp240}241// UnmarshalJSON unmarshal to json242func (richTextUnderline *RichTextUnderline) UnmarshalJSON(b []byte) error {243	var objMap map[string]*json.RawMessage244	err := json.Unmarshal(b, &objMap)245	if err != nil {246		return err247	}248	tempObj := struct {249		tdCommon250	}{}251	err = json.Unmarshal(b, &tempObj)252	if err != nil {253		return err254	}255	richTextUnderline.tdCommon = tempObj.tdCommon256	fieldText, _ := unmarshalRichText(objMap["text"])257	richTextUnderline.Text = fieldText258	return nil259}260// GetRichTextEnum return the enum type of this object261func (richTextUnderline *RichTextUnderline) GetRichTextEnum() RichTextEnum {262	return RichTextUnderlineType263}264// RichTextStrikethrough A strikethrough rich text265type RichTextStrikethrough struct {266	tdCommon267	Text RichText `json:"text"` // Text268}269// MessageType return the string telegram-type of RichTextStrikethrough270func (richTextStrikethrough *RichTextStrikethrough) MessageType() string {271	return "richTextStrikethrough"272}273// NewRichTextStrikethrough creates a new RichTextStrikethrough274//275// @param text Text276func NewRichTextStrikethrough(text RichText) *RichTextStrikethrough {277	richTextStrikethroughTemp := RichTextStrikethrough{278		tdCommon: tdCommon{Type: "richTextStrikethrough"},279		Text:     text,280	}281	return &richTextStrikethroughTemp282}283// UnmarshalJSON unmarshal to json284func (richTextStrikethrough *RichTextStrikethrough) UnmarshalJSON(b []byte) error {285	var objMap map[string]*json.RawMessage286	err := json.Unmarshal(b, &objMap)287	if err != nil {288		return err289	}290	tempObj := struct {291		tdCommon292	}{}293	err = json.Unmarshal(b, &tempObj)294	if err != nil {295		return err296	}297	richTextStrikethrough.tdCommon = tempObj.tdCommon298	fieldText, _ := unmarshalRichText(objMap["text"])299	richTextStrikethrough.Text = fieldText300	return nil301}302// GetRichTextEnum return the enum type of this object303func (richTextStrikethrough *RichTextStrikethrough) GetRichTextEnum() RichTextEnum {304	return RichTextStrikethroughType305}306// RichTextFixed A fixed-width rich text307type RichTextFixed struct {308	tdCommon309	Text RichText `json:"text"` // Text310}311// MessageType return the string telegram-type of RichTextFixed312func (richTextFixed *RichTextFixed) MessageType() string {313	return "richTextFixed"314}315// NewRichTextFixed creates a new RichTextFixed316//317// @param text Text318func NewRichTextFixed(text RichText) *RichTextFixed {319	richTextFixedTemp := RichTextFixed{320		tdCommon: tdCommon{Type: "richTextFixed"},321		Text:     text,322	}323	return &richTextFixedTemp324}325// UnmarshalJSON unmarshal to json326func (richTextFixed *RichTextFixed) UnmarshalJSON(b []byte) error {327	var objMap map[string]*json.RawMessage328	err := json.Unmarshal(b, &objMap)329	if err != nil {330		return err331	}332	tempObj := struct {333		tdCommon334	}{}335	err = json.Unmarshal(b, &tempObj)336	if err != nil {337		return err338	}339	richTextFixed.tdCommon = tempObj.tdCommon340	fieldText, _ := unmarshalRichText(objMap["text"])341	richTextFixed.Text = fieldText342	return nil343}344// GetRichTextEnum return the enum type of this object345func (richTextFixed *RichTextFixed) GetRichTextEnum() RichTextEnum {346	return RichTextFixedType347}348// RichTextURL A rich text URL link349type RichTextURL struct {350	tdCommon351	Text     RichText `json:"text"`      // Text352	URL      string   `json:"url"`       // URL353	IsCached bool     `json:"is_cached"` // True, if the URL has cached instant view server-side354}355// MessageType return the string telegram-type of RichTextURL356func (richTextURL *RichTextURL) MessageType() string {357	return "richTextUrl"358}359// NewRichTextURL creates a new RichTextURL360//361// @param text Text362// @param uRL URL363// @param isCached True, if the URL has cached instant view server-side364func NewRichTextURL(text RichText, uRL string, isCached bool) *RichTextURL {365	richTextURLTemp := RichTextURL{366		tdCommon: tdCommon{Type: "richTextUrl"},367		Text:     text,368		URL:      uRL,369		IsCached: isCached,370	}371	return &richTextURLTemp372}373// UnmarshalJSON unmarshal to json374func (richTextURL *RichTextURL) UnmarshalJSON(b []byte) error {375	var objMap map[string]*json.RawMessage376	err := json.Unmarshal(b, &objMap)377	if err != nil {378		return err379	}380	tempObj := struct {381		tdCommon382		URL      string `json:"url"`       // URL383		IsCached bool   `json:"is_cached"` // True, if the URL has cached instant view server-side384	}{}385	err = json.Unmarshal(b, &tempObj)386	if err != nil {387		return err388	}389	richTextURL.tdCommon = tempObj.tdCommon390	richTextURL.URL = tempObj.URL391	richTextURL.IsCached = tempObj.IsCached392	fieldText, _ := unmarshalRichText(objMap["text"])393	richTextURL.Text = fieldText394	return nil395}396// GetRichTextEnum return the enum type of this object397func (richTextURL *RichTextURL) GetRichTextEnum() RichTextEnum {398	return RichTextURLType399}400// RichTextEmailAddress A rich text email link401type RichTextEmailAddress struct {402	tdCommon403	Text         RichText `json:"text"`          // Text404	EmailAddress string   `json:"email_address"` // Email address405}406// MessageType return the string telegram-type of RichTextEmailAddress407func (richTextEmailAddress *RichTextEmailAddress) MessageType() string {408	return "richTextEmailAddress"409}410// NewRichTextEmailAddress creates a new RichTextEmailAddress411//412// @param text Text413// @param emailAddress Email address414func NewRichTextEmailAddress(text RichText, emailAddress string) *RichTextEmailAddress {415	richTextEmailAddressTemp := RichTextEmailAddress{416		tdCommon:     tdCommon{Type: "richTextEmailAddress"},417		Text:         text,418		EmailAddress: emailAddress,419	}420	return &richTextEmailAddressTemp421}422// UnmarshalJSON unmarshal to json423func (richTextEmailAddress *RichTextEmailAddress) UnmarshalJSON(b []byte) error {424	var objMap map[string]*json.RawMessage425	err := json.Unmarshal(b, &objMap)426	if err != nil {427		return err428	}429	tempObj := struct {430		tdCommon431		EmailAddress string `json:"email_address"` // Email address432	}{}433	err = json.Unmarshal(b, &tempObj)434	if err != nil {435		return err436	}437	richTextEmailAddress.tdCommon = tempObj.tdCommon438	richTextEmailAddress.EmailAddress = tempObj.EmailAddress439	fieldText, _ := unmarshalRichText(objMap["text"])440	richTextEmailAddress.Text = fieldText441	return nil442}443// GetRichTextEnum return the enum type of this object444func (richTextEmailAddress *RichTextEmailAddress) GetRichTextEnum() RichTextEnum {445	return RichTextEmailAddressType446}447// RichTextSubscript A subscript rich text448type RichTextSubscript struct {449	tdCommon450	Text RichText `json:"text"` // Text451}452// MessageType return the string telegram-type of RichTextSubscript453func (richTextSubscript *RichTextSubscript) MessageType() string {454	return "richTextSubscript"455}456// NewRichTextSubscript creates a new RichTextSubscript457//458// @param text Text459func NewRichTextSubscript(text RichText) *RichTextSubscript {460	richTextSubscriptTemp := RichTextSubscript{461		tdCommon: tdCommon{Type: "richTextSubscript"},462		Text:     text,463	}464	return &richTextSubscriptTemp465}466// UnmarshalJSON unmarshal to json467func (richTextSubscript *RichTextSubscript) UnmarshalJSON(b []byte) error {468	var objMap map[string]*json.RawMessage469	err := json.Unmarshal(b, &objMap)470	if err != nil {471		return err472	}473	tempObj := struct {474		tdCommon475	}{}476	err = json.Unmarshal(b, &tempObj)477	if err != nil {478		return err479	}480	richTextSubscript.tdCommon = tempObj.tdCommon481	fieldText, _ := unmarshalRichText(objMap["text"])482	richTextSubscript.Text = fieldText483	return nil484}485// GetRichTextEnum return the enum type of this object486func (richTextSubscript *RichTextSubscript) GetRichTextEnum() RichTextEnum {487	return RichTextSubscriptType488}489// RichTextSuperscript A superscript rich text490type RichTextSuperscript struct {491	tdCommon492	Text RichText `json:"text"` // Text493}494// MessageType return the string telegram-type of RichTextSuperscript495func (richTextSuperscript *RichTextSuperscript) MessageType() string {496	return "richTextSuperscript"497}498// NewRichTextSuperscript creates a new RichTextSuperscript499//500// @param text Text501func NewRichTextSuperscript(text RichText) *RichTextSuperscript {502	richTextSuperscriptTemp := RichTextSuperscript{503		tdCommon: tdCommon{Type: "richTextSuperscript"},504		Text:     text,505	}506	return &richTextSuperscriptTemp507}508// UnmarshalJSON unmarshal to json509func (richTextSuperscript *RichTextSuperscript) UnmarshalJSON(b []byte) error {510	var objMap map[string]*json.RawMessage511	err := json.Unmarshal(b, &objMap)512	if err != nil {513		return err514	}515	tempObj := struct {516		tdCommon517	}{}518	err = json.Unmarshal(b, &tempObj)519	if err != nil {520		return err521	}522	richTextSuperscript.tdCommon = tempObj.tdCommon523	fieldText, _ := unmarshalRichText(objMap["text"])524	richTextSuperscript.Text = fieldText525	return nil526}527// GetRichTextEnum return the enum type of this object528func (richTextSuperscript *RichTextSuperscript) GetRichTextEnum() RichTextEnum {529	return RichTextSuperscriptType530}531// RichTextMarked A marked rich text532type RichTextMarked struct {533	tdCommon534	Text RichText `json:"text"` // Text535}536// MessageType return the string telegram-type of RichTextMarked537func (richTextMarked *RichTextMarked) MessageType() string {538	return "richTextMarked"539}540// NewRichTextMarked creates a new RichTextMarked541//542// @param text Text543func NewRichTextMarked(text RichText) *RichTextMarked {544	richTextMarkedTemp := RichTextMarked{545		tdCommon: tdCommon{Type: "richTextMarked"},546		Text:     text,547	}548	return &richTextMarkedTemp549}550// UnmarshalJSON unmarshal to json551func (richTextMarked *RichTextMarked) UnmarshalJSON(b []byte) error {552	var objMap map[string]*json.RawMessage553	err := json.Unmarshal(b, &objMap)554	if err != nil {555		return err556	}557	tempObj := struct {558		tdCommon559	}{}560	err = json.Unmarshal(b, &tempObj)561	if err != nil {562		return err563	}564	richTextMarked.tdCommon = tempObj.tdCommon565	fieldText, _ := unmarshalRichText(objMap["text"])566	richTextMarked.Text = fieldText567	return nil568}569// GetRichTextEnum return the enum type of this object570func (richTextMarked *RichTextMarked) GetRichTextEnum() RichTextEnum {571	return RichTextMarkedType572}573// RichTextPhoneNumber A rich text phone number574type RichTextPhoneNumber struct {575	tdCommon576	Text        RichText `json:"text"`         // Text577	PhoneNumber string   `json:"phone_number"` // Phone number578}579// MessageType return the string telegram-type of RichTextPhoneNumber580func (richTextPhoneNumber *RichTextPhoneNumber) MessageType() string {581	return "richTextPhoneNumber"582}583// NewRichTextPhoneNumber creates a new RichTextPhoneNumber584//585// @param text Text586// @param phoneNumber Phone number587func NewRichTextPhoneNumber(text RichText, phoneNumber string) *RichTextPhoneNumber {588	richTextPhoneNumberTemp := RichTextPhoneNumber{589		tdCommon:    tdCommon{Type: "richTextPhoneNumber"},590		Text:        text,591		PhoneNumber: phoneNumber,592	}593	return &richTextPhoneNumberTemp594}595// UnmarshalJSON unmarshal to json596func (richTextPhoneNumber *RichTextPhoneNumber) UnmarshalJSON(b []byte) error {597	var objMap map[string]*json.RawMessage598	err := json.Unmarshal(b, &objMap)599	if err != nil {600		return err601	}602	tempObj := struct {603		tdCommon604		PhoneNumber string `json:"phone_number"` // Phone number605	}{}606	err = json.Unmarshal(b, &tempObj)607	if err != nil {608		return err609	}610	richTextPhoneNumber.tdCommon = tempObj.tdCommon611	richTextPhoneNumber.PhoneNumber = tempObj.PhoneNumber612	fieldText, _ := unmarshalRichText(objMap["text"])613	richTextPhoneNumber.Text = fieldText614	return nil615}616// GetRichTextEnum return the enum type of this object617func (richTextPhoneNumber *RichTextPhoneNumber) GetRichTextEnum() RichTextEnum {618	return RichTextPhoneNumberType619}620// RichTextIcon A small image inside the text621type RichTextIcon struct {622	tdCommon623	Document *Document `json:"document"` // The image represented as a document. The image can be in GIF, JPEG or PNG format624	Width    int32     `json:"width"`    // Width of a bounding box in which the image should be shown; 0 if unknown625	Height   int32     `json:"height"`   // Height of a bounding box in which the image should be shown; 0 if unknown626}627// MessageType return the string telegram-type of RichTextIcon628func (richTextIcon *RichTextIcon) MessageType() string {629	return "richTextIcon"630}631// NewRichTextIcon creates a new RichTextIcon632//633// @param document The image represented as a document. The image can be in GIF, JPEG or PNG format634// @param width Width of a bounding box in which the image should be shown; 0 if unknown635// @param height Height of a bounding box in which the image should be shown; 0 if unknown636func NewRichTextIcon(document *Document, width int32, height int32) *RichTextIcon {637	richTextIconTemp := RichTextIcon{638		tdCommon: tdCommon{Type: "richTextIcon"},639		Document: document,640		Width:    width,641		Height:   height,642	}643	return &richTextIconTemp644}645// GetRichTextEnum return the enum type of this object646func (richTextIcon *RichTextIcon) GetRichTextEnum() RichTextEnum {647	return RichTextIconType648}649// RichTextReference A reference to a richTexts object on the same web page650type RichTextReference struct {651	tdCommon652	Text       RichText `json:"text"`        // The text653	AnchorName string   `json:"anchor_name"` // The name of a richTextAnchor object, which is the first element of the target richTexts object654	URL        string   `json:"url"`         // An HTTP URL, opening the reference655}656// MessageType return the string telegram-type of RichTextReference657func (richTextReference *RichTextReference) MessageType() string {658	return "richTextReference"659}660// NewRichTextReference creates a new RichTextReference661//662// @param text The text663// @param anchorName The name of a richTextAnchor object, which is the first element of the target richTexts object664// @param uRL An HTTP URL, opening the reference665func NewRichTextReference(text RichText, anchorName string, uRL string) *RichTextReference {666	richTextReferenceTemp := RichTextReference{667		tdCommon:   tdCommon{Type: "richTextReference"},668		Text:       text,669		AnchorName: anchorName,670		URL:        uRL,671	}672	return &richTextReferenceTemp673}674// UnmarshalJSON unmarshal to json675func (richTextReference *RichTextReference) UnmarshalJSON(b []byte) error {676	var objMap map[string]*json.RawMessage677	err := json.Unmarshal(b, &objMap)678	if err != nil {679		return err680	}681	tempObj := struct {682		tdCommon683		AnchorName string `json:"anchor_name"` // The name of a richTextAnchor object, which is the first element of the target richTexts object684		URL        string `json:"url"`         // An HTTP URL, opening the reference685	}{}686	err = json.Unmarshal(b, &tempObj)687	if err != nil {688		return err689	}690	richTextReference.tdCommon = tempObj.tdCommon691	richTextReference.AnchorName = tempObj.AnchorName692	richTextReference.URL = tempObj.URL693	fieldText, _ := unmarshalRichText(objMap["text"])694	richTextReference.Text = fieldText695	return nil696}697// GetRichTextEnum return the enum type of this object698func (richTextReference *RichTextReference) GetRichTextEnum() RichTextEnum {699	return RichTextReferenceType700}701// RichTextAnchor An anchor702type RichTextAnchor struct {703	tdCommon704	Name string `json:"name"` // Anchor name705}706// MessageType return the string telegram-type of RichTextAnchor707func (richTextAnchor *RichTextAnchor) MessageType() string {708	return "richTextAnchor"709}710// NewRichTextAnchor creates a new RichTextAnchor711//712// @param name Anchor name713func NewRichTextAnchor(name string) *RichTextAnchor {714	richTextAnchorTemp := RichTextAnchor{715		tdCommon: tdCommon{Type: "richTextAnchor"},716		Name:     name,717	}718	return &richTextAnchorTemp719}720// GetRichTextEnum return the enum type of this object721func (richTextAnchor *RichTextAnchor) GetRichTextEnum() RichTextEnum {722	return RichTextAnchorType723}724// RichTextAnchorLink A link to an anchor on the same web page725type RichTextAnchorLink struct {726	tdCommon727	Text       RichText `json:"text"`        // The link text728	AnchorName string   `json:"anchor_name"` // The anchor name. If the name is empty, the link should bring back to top729	URL        string   `json:"url"`         // An HTTP URL, opening the anchor730}731// MessageType return the string telegram-type of RichTextAnchorLink732func (richTextAnchorLink *RichTextAnchorLink) MessageType() string {733	return "richTextAnchorLink"734}735// NewRichTextAnchorLink creates a new RichTextAnchorLink736//737// @param text The link text738// @param anchorName The anchor name. If the name is empty, the link should bring back to top739// @param uRL An HTTP URL, opening the anchor740func NewRichTextAnchorLink(text RichText, anchorName string, uRL string) *RichTextAnchorLink {741	richTextAnchorLinkTemp := RichTextAnchorLink{742		tdCommon:   tdCommon{Type: "richTextAnchorLink"},743		Text:       text,744		AnchorName: anchorName,745		URL:        uRL,746	}747	return &richTextAnchorLinkTemp748}749// UnmarshalJSON unmarshal to json750func (richTextAnchorLink *RichTextAnchorLink) UnmarshalJSON(b []byte) error {751	var objMap map[string]*json.RawMessage752	err := json.Unmarshal(b, &objMap)753	if err != nil {754		return err755	}756	tempObj := struct {757		tdCommon758		AnchorName string `json:"anchor_name"` // The anchor name. If the name is empty, the link should bring back to top759		URL        string `json:"url"`         // An HTTP URL, opening the anchor760	}{}761	err = json.Unmarshal(b, &tempObj)762	if err != nil {763		return err764	}765	richTextAnchorLink.tdCommon = tempObj.tdCommon766	richTextAnchorLink.AnchorName = tempObj.AnchorName767	richTextAnchorLink.URL = tempObj.URL768	fieldText, _ := unmarshalRichText(objMap["text"])769	richTextAnchorLink.Text = fieldText770	return nil771}772// GetRichTextEnum return the enum type of this object773func (richTextAnchorLink *RichTextAnchorLink) GetRichTextEnum() RichTextEnum {774	return RichTextAnchorLinkType775}776// RichTexts A concatenation of rich texts777type RichTexts struct {778	tdCommon779	Texts []RichText `json:"texts"` // Texts780}781// MessageType return the string telegram-type of RichTexts782func (richTexts *RichTexts) MessageType() string {...msg_encoding.go
Source:msg_encoding.go  
...31func marshalAmino(td EncodableTxData) (string, error) {32	bz, err := cdc.MarshalBinaryBare(td)33	return string(bz), err34}35func unmarshalAmino(td *EncodableTxData, text string) (err error) {36	return cdc.UnmarshalBinaryBare([]byte(text), td)37}38// MarshalAmino defines custom encoding scheme for TxData39func (td TxData) MarshalAmino() (string, error) {40	e := EncodableTxData{41		AccountNonce: td.AccountNonce,42		Price:        utils.MarshalBigInt(td.Price),43		GasLimit:     td.GasLimit,44		Recipient:    td.Recipient,45		Amount:       utils.MarshalBigInt(td.Amount),46		Payload:      td.Payload,47		V: utils.MarshalBigInt(td.V),48		R: utils.MarshalBigInt(td.R),49		S: utils.MarshalBigInt(td.S),50		Hash: td.Hash,51	}52	return marshalAmino(e)53}54// UnmarshalAmino defines custom decoding scheme for TxData55func (td *TxData) UnmarshalAmino(text string) (err error) {56	e := new(EncodableTxData)57	err = unmarshalAmino(e, text)58	if err != nil {59		return60	}61	td.AccountNonce = e.AccountNonce62	td.GasLimit = e.GasLimit63	td.Recipient = e.Recipient64	td.Payload = e.Payload65	td.Hash = e.Hash66	price, err := utils.UnmarshalBigInt(e.Price)67	if err != nil {68		return69	}70	if td.Price != nil {71		td.Price.Set(price)72	} else {73		td.Price = price74	}75	amt, err := utils.UnmarshalBigInt(e.Amount)76	if err != nil {77		return78	}79	if td.Amount != nil {80		td.Amount.Set(amt)81	} else {82		td.Amount = amt83	}84	v, err := utils.UnmarshalBigInt(e.V)85	if err != nil {86		return87	}88	if td.V != nil {89		td.V.Set(v)90	} else {91		td.V = v92	}93	r, err := utils.UnmarshalBigInt(e.R)94	if err != nil {95		return96	}97	if td.R != nil {98		td.R.Set(r)99	} else {100		td.R = r101	}102	s, err := utils.UnmarshalBigInt(e.S)103	if err != nil {104		return105	}106	if td.S != nil {107		td.S.Set(s)108	} else {109		td.S = s110	}111	return112}113// TODO: Implement JSON marshaling/ unmarshaling for this type114// TODO: Implement YAML marshaling/ unmarshaling for this type...unmarshal
Using AI Code Generation
1import (2type td struct {3}4func main() {5    b := []byte(`{"Name":"John", "Age":30}`)6    err := json.Unmarshal(b, &t)7    if err != nil {8        fmt.Println(err)9    }10    fmt.Println(t)11}12{John 30}13import (14type td struct {15}16func main() {17    t := td{"John", 30}18    b, err := json.MarshalIndent(t, "", "  ")19    if err != nil {20        fmt.Println(err)21    }22    fmt.Println(string(b))23}24{25}26import (27type td struct {28}29func main() {30    t := td{"John", 30}31    enc := json.NewEncoder(os.Stdout)32    err := enc.Encode(t)33    if err != nil {34        fmt.Println(err)35    }36    dec := json.NewDecoder(os.Stdin)37    err = dec.Decode(&t)38    if err != nil {39        fmt.Println(err)40    }41    fmt.Println(t)42}43{"Name":"John","Age":30}44{John 30}unmarshal
Using AI Code Generation
1import (2type TD struct {3}4func main() {5	xmlFile, err := ioutil.ReadFile("1.xml")6	if err != nil {7		log.Fatal(err)8	}9	xml.Unmarshal(xmlFile, &td)10	jsonFile, err := json.MarshalIndent(td, "", " ")11	if err != nil {12		log.Fatal(err)13	}14	fmt.Println(string(jsonFile))15}16{unmarshal
Using AI Code Generation
1import (2type TD struct {3}4func main() {5    td := TD{}6    data := []byte(`[{"id":"1","name":"sam","department":"sales","salary":"10000"},{"id":"2","name":"john","department":"sales","salary":"12000"}]`)7    err := json.Unmarshal(data, &td)8    if err != nil {9        log.Fatal(err)10    }11    fmt.Println(td)12}13{1 sam sales 10000}14{1 sam sales 10000}15{1 sam sales 10000}unmarshal
Using AI Code Generation
1import (2type td struct {3}4func main() {5	data := []byte(`{"FirstName":"Anil","LastName":"Kumar","Age":33,"Height":173,"Weight":70}`)6	json.Unmarshal(data, &t)7	fmt.Println(t)8}9Output: {Anil Kumar 33 173 70}10import (11type td struct {12}13func main() {14	t := td{}15	data := []byte(`{"FirstName":"Anil","LastName":"Kumar","Age":33,"Height":173,"Weight":70}`)16	json.Unmarshal(data, &t)17	fmt.Println(t)18}19Output: {Anil Kumar 33 173 70}20import (21type td struct {22}23func main() {24	t := &td{}25	data := []byte(`{"FirstName":"Anil","LastName":"Kumar","Age":33,"Height":173,"Weight":70}`)26	json.Unmarshal(data, &t)27	fmt.Println(t)28}29Output: &{Anil Kumar 33 173 70}30import (31type td struct {32}33func main() {34	t := td{}35	data := []byte(`{"FirstName":"Anil","LastName":"Kumar","Age":33,"Height":173,"Weight":70}`)36	json.Unmarshal(data, t)37	fmt.Println(t)38}39Output: { 0 0 0}40import (41type td struct {unmarshal
Using AI Code Generation
1import (2type Td struct {3}4func main() {5    td := Td{}6    b := []byte(`{"id":"1","name":"John","address":"NY"}`)7    err := json.Unmarshal(b, &td)8    if err != nil {9        fmt.Println("error:", err)10    }11    fmt.Printf("%+v", td)12}13{Id:1 Name:John Address:NY}14import (15type Td struct {16}17func main() {18    td := Td{Id: "1", Name: "John", Address: "NY"}19    b, err := json.Marshal(td)20    if err != nil {21        fmt.Println("error:", err)22    }23    fmt.Println(string(b))24}25{"id":"1","name":"John","address":"NY"}26import (27type Td struct {28}29func main() {30    td := Td{Id: "1", Name: "John", Address: "NY"}31    b, err := json.MarshalIndent(td, "", " ")32    if err != nil {33        fmt.Println("error:", err)34    }35    fmt.Println(string(b))36}37{38}39import (40type Td struct {41}42func main() {43    td := Td{Id: "1", Name: "John", Address: "NY"}44    b, err := json.MarshalIndent(td, "", " ")45    if err != nil {46        fmt.Println("error:", err)47    }48    fmt.Println(string(b))49}50{51}unmarshal
Using AI Code Generation
1import (2type td struct {3}4func main() {5	jsonString := `{"FirstName":"John","LastName":"Doe","Age":21}`6	err := json.Unmarshal([]byte(jsonString), &u)7	if err != nil {8		fmt.Println(err)9	}10	fmt.Println(u)11}12import (13type td struct {14}15func main() {16	jsonString := `{"FirstName":"John","LastName":"Doe","Age":21}`17	err := json.Unmarshal([]byte(jsonString), &u)18	if err != nil {19		fmt.Println(err)20	}21	fmt.Println(u)22	fmt.Println(u.FirstName)23}24import (25type td struct {26}27func main() {28	jsonString := `{"FirstName":"John","LastName":"Doe","Age":21}`29	err := json.Unmarshal([]byte(jsonString), &u)30	if err != nil {31		fmt.Println(err)32	}33	fmt.Println(u)34	fmt.Println(u.FirstName)35	fmt.Println(u.LastName)36}37import (38type td struct {39}40func main() {41	jsonString := `{"FirstName":"John","LastName":"Doe","Age":21}`unmarshal
Using AI Code Generation
1import (2func main() {3	json.Unmarshal([]byte(`{"name":"John", "age": 30, "cars": ["Ford", "BMW", "Fiat"]}`), &td)4	fmt.Println(td)5}6import (7func main() {8	json.Unmarshal([]byte(`{"name":"John", "age": 30, "cars": ["Ford", "BMW", "Fiat"]}`), &td)9	fmt.Println(td)10}11import (12func main() {13	json.Unmarshal([]byte(`{"name":"John", "age": 30, "cars": ["Ford", "BMW", "Fiat"]}`), &td)14	fmt.Println(td)15}16import (17func main() {18	json.Unmarshal([]byte(`{"name":"John", "age": 30, "cars": ["Ford", "BMW", "Fiat"]}`), &td)19	fmt.Println(td)20}21import (22func main() {23	json.Unmarshal([]byte(`{"name":"John", "age": 30, "cars": ["Ford", "BMW", "Fiat"]}`), &td)24	fmt.Println(td)25}26import (27func main() {28	json.Unmarshal([]byte(`{"name":"John", "age": 30, "cars": ["Ford", "BMW", "Fiat"]}`), &td)29	fmt.Println(td)30}31import (32func main() {33	json.Unmarshal([]byte(`{"name":"JohnLearn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
