Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Struct generation issue #24

Closed
Teddy-Schmitz opened this issue Feb 23, 2018 · 3 comments · Fixed by #29
Closed

Struct generation issue #24

Teddy-Schmitz opened this issue Feb 23, 2018 · 3 comments · Fixed by #29

Comments

@Teddy-Schmitz
Copy link

Teddy-Schmitz commented Feb 23, 2018

So sometimes when I'm running the generation I get this error,

expected Address to be a named struct, instead found string

and the interface will generate all the fields, but sometimes the generate runs successfully with no errors and its using the type I put in types.json.

I have been trying to figure out why this is happening, any clues?

@Teddy-Schmitz Teddy-Schmitz changed the title Odd Issue Struct generation issue Feb 23, 2018
@Teddy-Schmitz
Copy link
Author

If I change the name of the struct from Address to something else like AddressHolder this seems to go away. Now I'm guessing that I have something else called address somewhere.

@vektah
Copy link
Collaborator

vektah commented Feb 23, 2018

I have a feeling there is a nasty bug lurking in the model generation, it makes a dependency loop between the generated code and the user code.

generated.go contains Address, it might even reference some user type
user.go contains references to address

this means when regenerating the code the user code is invalid without the generated code (address is not defined). I think I'm going to need to split it into two phases:

  • generate the models, disable type checking, write out generated.go
  • generate the rest of generated.go with types on

I'll look into it some more, thanks for the report 👍

@Teddy-Schmitz
Copy link
Author

Ya that does sound like something that could be affecting me. I do have other structs which have an address field that is a string.

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

Successfully merging a pull request may close this issue.

2 participants