bsed / gorilla

Automatically exported from code.google.com/p/gorilla
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Problem when loading on structs that uses custom type properties. #21

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Define an alias to a basic type
2. Define a struct that has a property of the new type
3. Try to load a map using schema.Load

What is the expected output? What do you see instead?

The system should be capable of setting the value on the property, but instead, 
the system panics with a message that cannot convert from types.

Please provide any additional information below.

The following code demonstrates de situation.
I already come-up with a solution that solves the problem for me, will send a 
pull request later tonight.

package main

import (
    "gorilla.googlecode.com/hg/gorilla/schema"
)

type TString string

type TTipoComposto struct {
    Nome TString
}

func main() {
    v := map[string][]string {
        "Nome", {"Teste"},
    }
    tt := new(TTipoComposto)
    schema.Load(tt, v)
}

Original issue reported on code.google.com by andrebq on 14 Oct 2011 at 9:51

GoogleCodeExporter commented 9 years ago
Following the patch.
With the respective test of the new functionality

Original comment by andrebq on 14 Oct 2011 at 10:09

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks for this patch. I'll adapt it a little bit to also support []CustomType 
and map[string]CustomType.

Original comment by rodrigo.moraes on 15 Oct 2011 at 6:13

GoogleCodeExporter commented 9 years ago
This issue was closed by revision 3c32a5540bba.

Original comment by rodrigo.moraes on 15 Oct 2011 at 7:04