[go-nuts] Re: Flagging lazy-loaded fields as being unsafe to access directly

2017-11-19 Thread Nate Finch
Just use a comment. That's usually fine. // this is lazy loaded, use getBar() instead of directly accessing. "Don't do that" is a surprisingly feasible solution to a lot of programming problems. Not everything has to be enforced by tooling. On Sunday, November 19, 2017 at 9:08:47 PM UTC-5,

[go-nuts] Re: Flagging lazy-loaded fields as being unsafe to access directly

2017-11-19 Thread Traun Leyden
In this case I mean within the boundaries of a single package. I realize there is no way to enforce another package maintainer to call the method wrapper rather than the field directly, but I was wondering if people have come up with naming conventions such as a leading underscore to make it

[go-nuts] Re: Flagging lazy-loaded fields as being unsafe to access directly

2017-11-17 Thread Nicholas Hanley
In Go, lowercase identifiers are not visible outside the package in which they are defined (ref: Exported identifiers ). Your example declares foo in the main package but I assume your real code would be in its own package. What you can do is