FAQ
It is possible to access exported fields, even if the struct is not
exported, without using reflection :

https://play.golang.org/p/enHSJzInBX



Le mercredi 14 janvier 2015 11:46:28 UTC+1, Oliver a écrit :
A struct type that is not exported can have fields that are capitalized or
not:

type myType1 struct {
field1 string
field2 int
}

type myType2 struct {
Field1 string
Field2 int
}

Both types are not visible outside the package so the fields aren't,
either. But what's the idiomatic way to name those fields? Or doesn't it
matter at all?

I guess if I ever decided to export the type (and its fields), it would be
less work to rename just the type and not the fields also. But that's about
the only factor I can think of.

Any thoughts/opinions?

-Oliver
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 4 of 16 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJan 14, '15 at 10:46a
activeJan 17, '15 at 3:45a
posts16
users7
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase