Created
June 22, 2018 19:39
-
-
Save gagliardetto/d3c45a5cee6d943d5b51439960b082dd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/json" | |
"errors" | |
"fmt" | |
) | |
type Notification struct { | |
Error error `json:"error"` | |
} | |
func main() { | |
err := errors.New("transmission") | |
notification := Notification{ | |
Error: err, | |
} | |
rawJSON, err := json.Marshal(notification) | |
if err != nil { | |
panic(err) | |
} | |
fmt.Println(string(rawJSON)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Solution: