Skip to content

Instantly share code, notes, and snippets.

@chourobin
Created January 20, 2014 01:28
Show Gist options
  • Select an option

  • Save chourobin/8513490 to your computer and use it in GitHub Desktop.

Select an option

Save chourobin/8513490 to your computer and use it in GitHub Desktop.
Example creating structs on the fly
// http://play.golang.org/p/TVFHKUHO2p
package main
import "fmt"
import "encoding/json"
func main() {
type error struct {
Message string `json:"message"`
}
mapD := map[string]interface{}{"error": error{Message: "hi"}}
mapB, _ := json.Marshal(mapD)
fmt.Println(string(mapB))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment