Skip to content

Instantly share code, notes, and snippets.

@knzm
Created January 26, 2018 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save knzm/bb7f68184dbb790d45a19b0b8cd316d0 to your computer and use it in GitHub Desktop.
Save knzm/bb7f68184dbb790d45a19b0b8cd316d0 to your computer and use it in GitHub Desktop.
package main
import (
"encoding/json"
"fmt"
)
type Response struct {
Status string `json:"status"`
Error string `json:"error"`
ErrorCode string `json:"error_code"`
DebugInfo interface{} `json:"debug_info,omitempty"`
}
func main() {
b, _ := json.Marshal(Response{})
fmt.Printf("%s\n", b)
var x *int
res := Response{
DebugInfo: x,
}
b, _ = json.Marshal(res)
fmt.Printf("%s\n", b)
}
{"status":"","error":"","error_code":""}
{"status":"","error":"","error_code":"","debug_info":null}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment