gorilla/schema

[bug] Nested fields not encoded in dot format

Andrew-M-C opened this issue · 1 comments

Describe the bug
As described in decoder: Keys are "paths" in dotted notation to the struct fields and nested structs
However, encoder does not acted like this.

Versions

  • Go version: go1.16.2 darwin/amd64
  • package version: v1.2.0

Steps to Reproduce

package main

import (
	"fmt"
	
	"github.com/gorilla/schema"
)

type config struct {
	User struct{
		Username string `schema:"username"`
	} `schema:"user"`
}

func main() {
	c := config{}
	c.User.Username = "gorilla"
	
	m := map[string][]string{}
	enc := schema.NewEncoder()
	
	enc.Encode(&c, m)
	fmt.Printf("config by gorilla: %+v", m)
}
Expected config by gorilla: map[user.username:[gorilla]]
Actually got config by gorilla: map[username:[gorilla]]
stale commented

This issue has been automatically marked as stale because it hasn't seen a recent update. It'll be automatically closed in a few days.