| 1 | Source: golang-github-mitchellh-mapstructure |
| 2 | Section: golang |
| 3 | Priority: optional |
| 4 | Maintainer: Debian Go Packaging Team <[email protected]> |
| 5 | Uploaders: Kouhei Maeda <[email protected]>, |
| 6 | Anthony Fok <[email protected]>, |
| 7 | Tim Potter <[email protected]>, |
| 8 | Rules-Requires-Root: no |
| 9 | Build-Depends: debhelper-compat (= 13), |
| 10 | dh-sequence-golang, |
| 11 | golang-any, |
| 12 | Testsuite: autopkgtest-pkg-go |
| 13 | Standards-Version: 4.6.1 |
| 14 | Vcs-Browser: https://salsa.debian.org/go-team/packages/golang-github-mitchellh-mapstructure |
| 15 | Vcs-Git: https://salsa.debian.org/go-team/packages/golang-github-mitchellh-mapstructure.git |
| 16 | Homepage: https://github.com/mitchellh/mapstructure |
| 17 | XS-Go-Import-Path: github.com/mitchellh/mapstructure |
| 18 | |
| 19 | Package: golang-github-mitchellh-mapstructure-dev |
| 20 | Architecture: all |
| 21 | Multi-Arch: foreign |
| 22 | Depends: ${misc:Depends}, |
| 23 | ${shlibs:Depends}, |
| 24 | Description: library for decoding generic map values into native Go structures |
| 25 | mapstructure is a Go library for decoding generic map values to structures and |
| 26 | vice versa, while providing helpful error handling. |
| 27 | . |
| 28 | This library is most useful when decoding values from some data stream (JSON, |
| 29 | Gob, etc.) where you don't quite know the structure of the underlying data |
| 30 | until you read a part of it. You can therefore read a map[string]interface{} |
| 31 | and use this library to decode it into the proper underlying native Go |
| 32 | structure. |
| 33 | . |
| 34 | Go offers fantastic standard libraries for decoding formats such as JSON. The |
| 35 | standard method is to have a struct pre-created, and populate that struct from |
| 36 | the bytes of the encoded format. This is great, but the problem is if you have |
| 37 | configuration or an encoding that changes slightly depending on specific |
| 38 | fields. |
| 39 | . |
| 40 | Perhaps we can't populate a specific structure without first reading the "type" |
| 41 | field from the JSON. We could always do two passes over the decoding of the |
| 42 | JSON (reading the "type" first, and the rest later). However, it is much |
| 43 | simpler to just decode this into a map[string]interface{} structure, read the |
| 44 | "type" key, then use something like this library to decode it into the proper |
| 45 | structure. |