2
useVim
4y

help!
golang

Is there any way to omit empty embedded structs without using pointers?

Comments
  • 1
    I'm really a Go novice, but if you wouldn't mind I'd love to see your scenario
  • 0
    Afaik there is no such option directly.
    You could use interfaces but they require a named struct and methods to be defined.
    Another option is to use other things to validate if the struct should be used. If a function return your struct this func can return a bool as well to indecate if the struct should be used.
  • 1
    @ScriptCoded
    I could use pointers to the embedded struct

    but the auto generated function returns normal value and an error.

    so I couldn't use pointer, since I can't assign normal value to a pointer variable.

    I have a workaround code for now.
Add Comment