An open API service providing repository metadata for many open source software ecosystems.

Package Usage: go: github.com/mitchellh/mapstructure

Package mapstructure exposes functionality to convert one arbitrary Go type into another, typically to convert a map[string]interface{} into a native Go structure. The Go structure can be arbitrarily complex, containing slices, other structs, etc. and the decoder will properly decode nested maps and so on into the proper structures in the native Go struct. See the examples to see what the decoder is capable of. The simplest function to start with is Decode. When decoding to a struct, mapstructure will use the field name by default to perform the mapping. For example, if a struct has a field "Username" then mapstructure will look for a key in the source value of "username" (case insensitive). You can change the behavior of mapstructure by using struct tags. The default struct tag that mapstructure looks for is "mapstructure" but you can customize it using DecoderConfig. To rename the key that mapstructure looks for, use the "mapstructure" 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. By default, the two structs below are equivalent when decoding with mapstructure: This would require an input that looks like below: If your "person" value is NOT nested, then you can append ",squash" to your tag value and mapstructure will treat it as if the embedded struct were part of the struct directly. Example: Now the following input would be accepted: When decoding from a struct to a map, the squash tag squashes the struct fields into a single map. Using the example structs from above: Will be decoded into a map: DecoderConfig has a field that changes the behavior of mapstructure to always squash embedded structs. If there are any unmapped keys in the source value, mapstructure by default will silently ignore them. You can error by setting ErrorUnused in DecoderConfig. If you're using Metadata you can also maintain a slice of the unused keys. You can also use the ",remain" suffix on your tag to collect all unused values in a map. The field with this tag MUST be a map type and should probably be a "map[string]interface{}" or "map[interface{}]interface{}". See example below: Given the input below, Other would be populated with the other values that weren't used (everything but "name"): When decoding 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 decoder will simply skip them. For this output type definition: Using this map as input: The following struct will be decoded: mapstructure is highly configurable. See the DecoderConfig struct for other features and options that are supported.
17 versions
Latest release: about 3 years ago
32,864 dependent packages

View more package details: https://packages.ecosystem.code.gouv.fr/registries/proxy.golang.org/packages/github.com/mitchellh/mapstructure

Dependent Repos 28

rferrand/go-config-files-utils
Go library providing various helpers to work with configuration files

Last synced: 12 months ago - Pushed: 11 months ago

1024pix/steampipe-plugin-learningcontent
Steampipe plugin to query LCMS content

Size: 101 KB - Last synced: 2 days ago - Pushed: over 1 year ago

1024pix/steampipe-plugin-metabase
Use SQL to query databases, tables, permissions and more from Metabase

Size: 1.22 MB - Last synced: 2 days ago - Pushed: 3 days ago

E218662B/web-api-rest-en-go-lang

Last synced: 12 months ago - Pushed: 11 months ago

E21A429P/tp_web_rest

Last synced: 12 months ago - Pushed: 11 months ago

swh/infra/ci-cd/3rdparty/alertmanager-irc-relay

Last synced: 7 months ago - Pushed: 11 months ago

swh/infra/ci-cd/3rdparty/cert-manager-webhook-gandi

Last synced: 7 months ago - Pushed: 11 months ago

guillaume.perreal/coord

Last synced: 11 months ago - Pushed: 11 months ago

radiofrance/dib
An opinionated docker image builder

Size: 3.61 MB - Last synced: 6 days ago - Pushed: 6 days ago

radiofrance/image-registry-metrics-exporter
Image Registry Metrics Exporter provides metrics about creation and uploading time of images on OCI registry.

Size: 302 KB - Last synced: 6 days ago - Pushed: 6 days ago

betagouv/sealed-secrets Fork of bitnami-labs/sealed-secrets
A Kubernetes controller and tool for one-way encrypted Secrets

Size: 19.2 MB - Last synced: 6 days ago - Pushed: almost 3 years ago

betagouv/vouch-proxy Fork of vouch/vouch-proxy
an SSO and OAuth / OIDC login solution for Nginx using the auth_request module

Size: 5.68 MB - Last synced: 6 days ago - Pushed: over 1 year ago

1024pix/steampipe-plugin-github Fork of turbot/steampipe-plugin-github
Use SQL to instantly query repositories, users, gists and more from GitHub. Open source CLI. No DB required.

Size: 206 KB - Last synced: 2 days ago - Pushed: about 1 year ago

signaux-faibles/opensignauxfaibles Fork of entrepreneur-interet-general/opensignauxfaibles
Plateforme de détection des entreprises fragiles

Size: 36.6 MB - Last synced: 6 days ago - Pushed: 3 months ago

radiofrance/ipahealthcheck_exporter Fork of camptocamp/ipahealthcheck_exporter
Prometheus exporter for exposing ipa-healthcheck tool checks as metrics

Size: 60.5 KB - Last synced: 6 days ago - Pushed: almost 4 years ago

signaux-faibles/wekan-alerter
wekan-alerter

Size: 44.9 KB - Last synced: 6 days ago - Pushed: over 2 years ago

signaux-faibles/libwekan

Size: 218 KB - Last synced: 6 days ago - Pushed: 11 months ago

signaux-faibles/IamUpdater
keycloakUpdater pour Signaux-Faibles

Size: 615 KB - Last synced: 6 days ago - Pushed: 11 months ago

signaux-faibles/goup
Serveur minimaliste pour téléverser des fichiers avec une gestion de droits

Size: 63.1 MB - Last synced: 6 days ago - Pushed: over 2 years ago

signaux-faibles/datapi
datAPI - API des applications web signaux-faibles

Size: 43.1 MB - Last synced: 6 days ago - Pushed: about 1 month ago

signaux-faibles/prepare-import
📥 Scripts de préparation à l'importation de données dans le processus d'intégration

Size: 276 KB - Last synced: 6 days ago - Pushed: 4 months ago

pass-culture/pc-monitoring 📦

Size: 176 MB - Last synced: 7 months ago - Pushed: over 3 years ago

capsule/drv

Last synced: 7 months ago - Pushed: 11 months ago

radiofrance/helm-chart-sonarqube Fork of SonarSource/helm-chart-sonarqube

Size: 2.99 MB - Last synced: 7 months ago - Pushed: 9 months ago

web-et-numerique/factory/llle_project/cozy-stack
Fork of cozy-stack https://github.com/cozy/cozy-stack

Last synced: 7 months ago

csan/csan
CSAN : A marketplace for science

Last synced: 7 months ago

impl-mentation-s105/gestion-de-particule

Last synced: 7 months ago - Pushed: 11 months ago

fantastic-fanfare/adorable_alien

Last synced: 7 months ago