Skip to content

type **time.Time has no field or method #160

@jgautheron

Description

@jgautheron

With the code generated from the setup below, I'm getting the following error:

models/survey_helper.go:48: tmp1.EndsAtToEndsAt undefined (type **time.Time has no field or method EndsAtToEndsAt)
models/survey_helper.go:52: tmp2.StartsAtToStartsAt undefined (type *time.Time has no field or method StartsAtToStartsAt)

Here's the relevant generated part from models/survey_helper.go:

// SurveyToSurvey loads a Survey and builds the default view of media type Survey.
func (m *Survey) SurveyToSurvey() *app.Survey {
	survey := &app.Survey{}
	tmp1 := &m.EndsAt
	survey.EndsAt = tmp1.EndsAtToEndsAt() // %!s(MISSING)
	survey.ID = m.ID
	survey.Name = m.Name
	tmp2 := &m.StartsAt
	survey.StartsAt = tmp2.StartsAtToStartsAt() // %!s(MISSING)
	survey.Status = m.Status

	return survey
}

Setup

// models.go
// extract from StorageGroup
Model("Survey", func() {
  BuildsFrom(func() {
    Payload("survey", "create")
    Payload("survey", "update")
  })
  RendersTo(SurveyMedia)
  HasMany("Questions", "Question")
  Field("id", gorma.UUID, func() {
    PrimaryKey()
  })
})

// payload.go
var SurveyPayload = Type("SurveyPayload", func() {
	Reference(SurveyMedia)
	Attribute("name")
	Attribute("startsAt")
	Attribute("endsAt")
	Attribute("status")
	Required("name")
})

// media_types.go
var SurveyMedia = MediaType("application/vnd.survey+json", func() {
	Description("A survey")
	Attributes(func() {
		Attribute("id", UUID, "Unique survey ID")
		Attribute("name", String, "Name of survey")
		Attribute("startsAt", DateTime, "Start date")
		Attribute("endsAt", DateTime, "End date")
                // ...
	})
})

Any idea what might be wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions