Answers for "JSON marshal errors"

0

JSON marshal errors

// convert errors into panics with a MustMarshal function 
to deal with handling errors in every marshal


func MustMarshal(data interface{}) []byte {
    out, err := json.Marshal(data)
    if err != nil {
        panic(err)
    }

    return out
}
Posted by: Guest on February-16-2022

Browse Popular Code Answers by Language