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

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:

Ecosystem
proxy.golang.org
Latest Release
v0.0.7
over 3 years ago
Versions
7
v0.0.7
Published: over 3 years ago
Registry - Documentation - Download
v0.0.6
Published: almost 4 years ago
Registry - Documentation - Download
v0.0.5
Published: about 4 years ago
Registry - Documentation - Download
v0.0.4
Published: about 4 years ago
Registry - Documentation - Download
v0.0.3
Published: over 4 years ago
Registry - Documentation - Download
v0.0.2
Published: over 4 years ago
Registry - Documentation - Download
v0.0.1
Published: over 4 years ago
Registry - Documentation - Download
Links
Registry proxy.golang.org
Source Repository
Docs Documentation
JSON API View JSON
CodeMeta codemeta.json
Package Details
PURL pkg:golang/github.com/things-go/mapstruct
spec
License MIT
Namespace github.com/things-go
First Release over 4 years ago
Last Synced 13 days ago
Repository
Stars 1 on GitHub
Forks 0 on GitHub
Rankings on proxy.golang.org
Overall Top 8.2%