On Wednesday, November 9, 2011 5:18:58 PM UTC+1, Archos wrote:
Any way to copy struct with private fields?
No. Intentionally not allowed. There may be some state in it which must be initialized and/or not reused and/or unique to its instance etc. Knowing/looking at the (imported package) sources doesn't help as the struct type private internals (and their semantics) can change at any time in the future - without breaking the public/exported API.
"If T is a struct type with non-exported fields, the assignment must be in the same package in which T is declared, or x must be the receiver of a method call. In other words, a struct value can be assigned to a struct variable only if every field of the struct may be legally assigned individually by the program, or if the assignment is initializing the receiver of a method of the struct type."