Documentation ¶
Overview ¶
Package priv focuses on privatizing data in your Go application.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ToMap ¶
func ToMap(item interface{}, fieldsToInclude ...string) interface{}
ToMap converts the item (struct or array of structs) to a map. Only the fields in the fieldsToInclude list are included. This list supports the dot operator to access nested fields, as well as the -> operator to rename a nested field. This function panics if the field cannot be found or set. If you are calling this function with a dynamically built list of fieldsToInclude, you may want to use the priv.ToMapErr alternative.
eg.
users := [{ID: "123", Some: {Nested: {Field: "abc"}}, SomethingElse: true}] ToMap(users, "ID", "Some.Nested.Field->Renamed.Location")
would result in:
[{ID: "123", Renamed: {Location: "abc"}}]
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.