An open API service providing package, version and dependency metadata of many open source software ecosystems and registries.

Top 8.2% on proxy.golang.org

proxy.golang.org : github.com/things-go/mapstruct

Package structs Go library for encoding native Go structures into generic map values. The simplest function to start with is Encoded. When encode to a map[string]interface{}, structs will use the field name by default to perform the mapping. For example, if a struct has a field "Username" then structs will use a key "Username". You can change the behavior of structs by using struct tags. The default struct tag that structs looks for is "map" but you can customize it using EncodeWithTag. To rename the key that structs looks for, use the "map" tag and set a value directly. For example, to change the "username" example above to "user": Embedded structs are treated as if they're another field with that name. This would output that looks like below: When encoding from a struct to any other value, you may use the ",omitempty" suffix on your tag to omit that value if it equates to the zero value. The zero value of all types is specified in the Go specification. For example, the zero type of a numeric type is zero ("0"). If the struct field value is zero and a numeric type, the field is empty, and it won't be encoded into the destination type. Since unexported (private) struct fields cannot be set outside the package where they are defined, the encoder will simply skip them. For this input type definition: this map as output:

Registry - Source - Documentation - JSON
purl: pkg:golang/github.com/things-go/mapstruct
License: MIT
Latest release: almost 3 years ago
First release: over 3 years ago
Namespace: github.com/things-go
Stars: 1 on GitHub
Forks: 0 on GitHub
See more repository details: repos.ecosyste.ms
Last synced: 3 days ago

    Loading...
    Readme
    Loading...