In one of the recent releases of quicktype, native time type support has been added for Go. I have had some success with this but there seems to be a bug where in some circumstances the time.Time type is being referenced in the generated code but the import for "time" is not being added.
// This file was generated from JSON Schema using quicktype, do not modify it directly.
// To parse and unparse this JSON data, add this code to your project and do:
//
// models, err := UnmarshalModels(bytes)
// bytes, err = models.Marshal()
package generated
import "encoding/json"
func UnmarshalModels(data []byte) (Models, error) {
var r Models
err := json.Unmarshal(data, &r)
return r, err
}
func (r *Models) Marshal() ([]byte, error) {
return json.Marshal(r)
}
type Models struct {
TimeRange []time.Time `json:"timeRange"`
}
Notice: the import for "time" is missing despite the reference to the package in the struct definition.
In one of the recent releases of quicktype, native time type support has been added for Go. I have had some success with this but there seems to be a bug where in some circumstances the time.Time type is being referenced in the generated code but the import for "time" is not being added.
Steps to reproduce, use the following schema:
Run generation command:
The generated models.go file:
Notice: the import for "time" is missing despite the reference to the package in the struct definition.