import ( "github.com/atnet/gof" ) func main() { // make API call response, err := makeAPICall() // check for error in API response if err != nil { msgResult := gof.MessageResult{Err: err, Msg: "API call failed"} handleAPIFailure(msgResult) } // API call was successful msgResult := gof.MessageResult{Msg: "API call succeeded"} handleAPISuccess(msgResult) }
import ( "github.com/atnet/gof" ) func main() { // make API call response, err := makeAPICall() // check for error in API response if err != nil { msgResult := gof.MessageResult{Err: err, Msg: "API call failed"} // return Message Result as JSON jsonMsgResult, _ := json.Marshal(msgResult) fmt.Println(string(jsonMsgResult)) } // API call was successful msgResult := gof.MessageResult{Msg: "API call succeeded"} // return Message Result as JSON jsonMsgResult, _ := json.Marshal(msgResult) fmt.Println(string(jsonMsgResult)) }In this example, the Message Result is used to return a JSON response indicating the success or failure of an API call. If an error is returned by the API call, then a Message Result object is created with the error object and a failure message, and then returned as JSON. If the API call is successful, then a Message Result object with a success message is created and returned as JSON. Overall, the Message Result function in the github.com/atnet/gof package library provides a simple way to handle API responses and indicate the success or failure of an API call.