I am interested in reading a schemas(json formatted text file) and unmarshall it as schemas (for which i have some JSON structures defined in a .GO file) and For each type of structure in the Schema, I want to generate a corresponding .go file which has the code for performing CRUD operations using the template package (http://golang.org/pkg/text/template/) to generate these files.
Example of a structure in a schema file - {
type struct XYZ {
Type string `json:"type,omitempty"`
ResourceType string `json:"resourceType,omitempty"`
Links map[string]string `json:"links,omitempty"`
}
The text file has a JSON structured data which is something of this form -
{
"type": "collection",
"resourceType": "schema",
"links": {
"self": "…/v1/schemas",
},
"createTypes": { },
"actions": { },
"data": [ 86 items
{
"id": "schema",
"type": "schema",
"links": {
"self": "/schemas/schema",
"collection": "…/schemas",
},
...
}
}
Could somebody help me how could i possibly generate the code for these CRUD operations for different structs using the GO template package.
You might find
go generate
useful.