Skip to content
This repository has been archived by the owner on Feb 21, 2022. It is now read-only.

If an entity type starts with the letter "i" $.Receiver is "i" breaking Code Gen #5

Closed
SteveCastle opened this issue Aug 7, 2021 · 2 comments

Comments

@SteveCastle
Copy link
Contributor

# templates/response.tmpl
func NewIndividualListResponse(i []*ent.Individual) IndividualListResponse {
	r := make(IndividualListResponse, len(i))
	for i := range i {
		r[i] = struct {
			ID      int    `json:"id,omitempty"`
			IRI     string `json:"IRI,omitempty"`
			Hash    string `json:"hash,omitempty"`
			Comment string `json:"comment,omitempty"`
		}{
			ID:      i[i].ID,
			IRI:     i[i].IRI,
			Hash:    i[i].Hash,
			Comment: i[i].Comment,
		}
	}
	return r
}

Entity struct argument name is shadowed by iterator in loop if $.Receiver is "i" This happens if the Entity Type starts with that letter.

@masseelch
Copy link
Owner

masseelch commented Aug 7, 2021

Hey @SteveCastle, thanks for reporting this. Feel free to create an PR. I can do it on Monday.

@SteveCastle SteveCastle changed the title If an entity type starts with the letter "i" $.Reciver is "i" breaking Code Gen If an entity type starts with the letter "i" $.Reciever is "i" breaking Code Gen Aug 7, 2021
@SteveCastle SteveCastle changed the title If an entity type starts with the letter "i" $.Reciever is "i" breaking Code Gen If an entity type starts with the letter "i" $.Receiver is "i" breaking Code Gen Aug 7, 2021
@SteveCastle
Copy link
Contributor Author

#6

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants