#This is also a bit strange behavior

1 messages · Page 1 of 1 (latest)

hallow breach
#

Looking at this one too, the behavior here is technically expected but I get why it's surprising.

Basically, when you define your struct here: https://github.com/levlaz/daggerverse/blob/689f042bb132df7b3d9af99bdc3538424fc0058c/launchdarkly/main.go#L8-L22

You are giving callers access not only to the methods you define on it (i.e. Find) but also all of the fields in that struct.

It's nice in that it saves devs from having to write a bunch of boilerplate "getter" methods that just return the fields in the struct. So e.g. if you actually wanted outside callers to have access to LaunchdarklyVersion you don't have to write an extra:

func (m *Launchdarkly) LaunchdarklyVersion() string {
  return m.LaunchdarklyVersion
}

But it's not nice if you didn't want to actually expose those fields to outside callers.

We just added support for a way of marking fields like that as private in Go. Let me check if it was in v0.9.4 or just after

hollow hazel
#

Got it, thanks so much for helping me understand this!