3 ms·
There are, actually --- any field which begins with a lower case letter is private, any field which begins with an upper case letter is public. (Don't ask me wh
by david-given 10y ago
There are, actually --- any field which begins with a lower case letter is private, any field which begins with an upper case letter is public. (Don't ask me what happens if the field begins with a letter which has a single form and does not have an explicit upper or lower case.)
Privacy is only enforced between packages, so anything in the same package as the struct can see the private fields.
- lloeki 10y ago> Don't ask me what happens if the field begins with a letter which has a single form and does not have an explicit upper or lower case. So, on to the spec: https://golang.org/ref/spec#unicode_letter https://golang.org/ref/spec#unicode_letter > In The Unicode Standard 8.0, Section 4.5 "General Category" defines a set of character categories. Go treats all characters in any of the Letter categories Lu, Ll, Lt, Lm, or Lo as Unicode letters, and those in the Number category Nd as Unicode digits. Which reads: Lu = Letter, uppercase Ll = Letter, lowercase Lt = Letter, titlecase Lm = Letter, modifier Lo = Letter, other So I suppose (but am not sure) the case you describe falls into Lo.