0

I'm sharing structs across packages, by putting the structs into their own package and importing it, and I'm wondering if the compiler will include ALL the structs, even unused ones, when compiling? I've tried Googling, but I can't really find anything specifically about this.

Kieran W.
  • 117
  • 9
  • 5
    Go is a language specification, not a compiler. So there's no definitive answer to this, as it depends on the compiler implementation. But one can generally assume that any reasonable compiler will remove unused code. – Flimzy May 30 '20 at 11:32
  • 1
    If it's not used, it won't be included in the binary. That's why you can't access types by string names with reflection. – icza May 30 '20 at 11:38

0 Answers0