Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Conversation

@vaguecoder
Copy link

Motivation

Issue #279 reported by @kszafran

Changes

Check in decode struct -> map for extra fields encoded with remain tag, and flatten in resultant map. Add corresponding tests:

  1. Unit test to decode struct (with remain-field) to map.
  2. Unit test to check invalid remain-field type check error.
  3. Example test to decode map -> struct -> map.
  4. Benchmark test to decode map -> struct -> map.

Summary

As extra fields are added to the remain-field while decoding map as structure, the reverse should work as well. i.e., while decoding structure as map, the extra fields in remain-field should get flattened in previous level. For code example, refer #279.

Related Issues

Closes #279

@sagikazarmark
Copy link

Pulled in at go-viper#8

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Encode a struct with ",remain" back to a map?

2 participants