Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added register custom type: closes #5
- Loading branch information
Showing
6 changed files
with
169 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ tmp | |
*.[568vq] | ||
[568vq].out | ||
|
||
formam_laboratory_test.go | ||
*.cgo1.go | ||
*.cgo2.c | ||
_cgo_defun.c | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package formam | ||
|
||
import ( | ||
"fmt" | ||
"net/url" | ||
"testing" | ||
) | ||
|
||
type Field string | ||
|
||
type Laboratory struct { | ||
MapWithStruct3Key map[Field]string | ||
Jodete Field | ||
} | ||
|
||
var valss = url.Values{ | ||
"Jodete": []string{"2006-01-02"}, | ||
//"MapWithStruct3Key[ID.ID]": []string{"struct key in map"}, | ||
} | ||
|
||
func TestLaboratory(t *testing.T) { | ||
var m Laboratory | ||
dec := NewDecoder(nil) | ||
dec.RegisterCustomType(func(vals []string) (interface{}, error) { | ||
return Field("value changed by custom type"), nil | ||
}, Field("")) | ||
err := dec.Decode(valss, &m) | ||
if err != nil { | ||
t.Error(err) | ||
t.FailNow() | ||
} | ||
fmt.Println("RESULT1: ", m) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters