Skip to content

Releases: go-playground/form

Release 3.1.1

08 Apr 17:04
6b988ba
Compare
Choose a tag to compare

What was fixed?

in PR #32:

  • Corrected handling of array, not slice, values that can lead to
    a panic.
  • Rearranged logic to handle multiple values if index and non-index are
    mixed eg. Value=[]string{"1","2"} Value[2]=[]string{"3"}

this resolves #29 and #30

Release 3.1.0

04 Feb 18:04
7fecd71
Compare
Choose a tag to compare

What was added

  • Added setting for string form value into interface{} values; previously they were ignored. thanks @Xzya for the issue

Why only string and not int, float etc...?
Because theres no way to tell what type the value should be; just because it CAN be parsed into an int, doesn't mean it should be for your application and so I have left it at setting strings.

Release 3.0.1

11 Sep 04:54
Compare
Choose a tag to compare

What was fixed?

empty boolean values are now set to false see here for details thanks @vearutop

Release 3.0.0

31 Jul 00:50
Compare
Choose a tag to compare

What's new?

  • Added Embedded struct support
  • Added omitempty just like std lib JSON

Made a version bump to v3.0.0 because the new Embedded struct logic has the potential to affect existing clients.

The Encoder has a new option SetAnonymousMode(...) by default it embeds anonymous struct info as if the fields were part of the containing struct itself; to continue to have it split out the Embedded structs just set mode to AnonymousSeparate and it will function exactly as previous versions.

please see examples detailing new functionality.

NOTE: if a struct and embedded struct have the same field, this will decode the value into both fields as there is no way to tell which you want; decoding into only the Embedded struct is still supported, again see examples.

Thanks to @danielchatfield and @michael2m for creating issues to get these features on the radar 👍

Release 2.3.0

16 Feb 00:37
Compare
Choose a tag to compare

What was added?

Added a new function to both the Decoder and Encoder called RegisterTagNameFunc.

NOTES:

Once a custom function has been registered the default, or custom set, tag name is ignored and relies 100% on the function for the field name data.

The return value WILL BE CACHED and so return value must be CONSISTENT.

Release 2.2.2

15 Feb 12:41
Compare
Choose a tag to compare

What was fixed?

  • Parsing of struct tag, by name, corrected for when multiple tags exists, this was corrected in #15 thanks @htmd

P.S. in the future, I will change this so that instead of specifying the tag name, a function will be specified allowing for greater flexibility; but it would be a breaking change so leaving for now until needed.

Release 2.2.1

13 Feb 01:55
Compare
Choose a tag to compare

What was fixed?

  • Added additional notes to RegisterCustomTypeFunc to indicate that if a struct type is registered a url.Value must exist explicitly for the struct and not just the fields.

eg. url.Values{"User":"Name%3Djoeybloggs"} will call the custom type function with User as the type, however url.Values{"User.Name":"joeybloggs"} will not.

Fixes #14

Release 2.2.0

23 Aug 21:23
Compare
Choose a tag to compare

What was added?

Added Mode to both the Encoder and Decoder and can be set with the SetMode(mode) function on either.

currently there are 2 modes:

  • ModeImplicit - the default mode, looks through all fields to encode or decode values
  • ModeExplicit - looks through only field marked explicitly with the form tag name

this is for #10 thanks @annismckenzie for the idea

no breaking changes, just update and enjoy.

Release 2.1.0

02 Aug 01:28
Compare
Choose a tag to compare

What was added?

  • Just some more minor backend performance updates, no changes.

benchmark                                                       old ns/op     new ns/op     delta
BenchmarkSimpleUserDecodeStruct-8                               318           336           +5.66%
BenchmarkSimpleUserDecodeStructParallel-8                       95.2          99.5          +4.52%
BenchmarkSimpleUserEncodeStruct-8                               1000          972           -2.80%
BenchmarkSimpleUserEncodeStructParallel-8                       325           329           +1.23%
BenchmarkPrimitivesDecodeStructAllPrimitivesTypes-8             1058          1014          -4.16%
BenchmarkPrimitivesDecodeStructAllPrimitivesTypesParallel-8     324           294           -9.26%
BenchmarkPrimitivesEncodeStructAllPrimitivesTypes-8             4823          4799          -0.50%
BenchmarkPrimitivesEncodeStructAllPrimitivesTypesParallel-8     1732          1581          -8.72%
BenchmarkComplexArrayDecodeStructAllTypes-8                     16340         16326         -0.09%
BenchmarkComplexArrayDecodeStructAllTypesParallel-8             5105          4710          -7.74%
BenchmarkComplexArrayEncodeStructAllTypes-8                     16343         16303         -0.24%
BenchmarkComplexArrayEncodeStructAllTypesParallel-8             5969          4979          -16.59%
BenchmarkComplexMapDecodeStructAllTypes-8                       21259         21998         +3.48%
BenchmarkComplexMapDecodeStructAllTypesParallel-8               7493          6542          -12.69%
BenchmarkComplexMapEncodeStructAllTypes-8                       17060         17069         +0.05%
BenchmarkComplexMapEncodeStructAllTypesParallel-8               6421          5609          -12.65%
BenchmarkDecodeNestedStruct-8                                   3488          3366          -3.50%
BenchmarkDecodeNestedStructParallel-8                           1203          1096          -8.89%
BenchmarkEncodeNestedStruct-8                                   2286          2230          -2.45%
BenchmarkEncodeNestedStructParallel-8                           939           780           -16.93%

benchmark                                                       old allocs     new allocs     delta
BenchmarkSimpleUserDecodeStruct-8                               1              1              +0.00%
BenchmarkSimpleUserDecodeStructParallel-8                       1              1              +0.00%
BenchmarkSimpleUserEncodeStruct-8                               12             11             -8.33%
BenchmarkSimpleUserEncodeStructParallel-8                       12             11             -8.33%
BenchmarkPrimitivesDecodeStructAllPrimitivesTypes-8             1              1              +0.00%
BenchmarkPrimitivesDecodeStructAllPrimitivesTypesParallel-8     1              1              +0.00%
BenchmarkPrimitivesEncodeStructAllPrimitivesTypes-8             47             46             -2.13%
BenchmarkPrimitivesEncodeStructAllPrimitivesTypesParallel-8     47             46             -2.13%
BenchmarkComplexArrayDecodeStructAllTypes-8                     122            121            -0.82%
BenchmarkComplexArrayDecodeStructAllTypesParallel-8             122            121            -0.82%
BenchmarkComplexArrayEncodeStructAllTypes-8                     147            146            -0.68%
BenchmarkComplexArrayEncodeStructAllTypesParallel-8             147            146            -0.68%
BenchmarkComplexMapDecodeStructAllTypes-8                       131            130            -0.76%
BenchmarkComplexMapDecodeStructAllTypesParallel-8               131            130            -0.76%
BenchmarkComplexMapEncodeStructAllTypes-8                       176            175            -0.57%
BenchmarkComplexMapEncodeStructAllTypesParallel-8               176            175            -0.57%
BenchmarkDecodeNestedStruct-8                                   15             14             -6.67%
BenchmarkDecodeNestedStructParallel-8                           15             14             -6.67%
BenchmarkEncodeNestedStruct-8                                   17             16             -5.88%
BenchmarkEncodeNestedStructParallel-8                           17             16             -5.88%

benchmark                                                       old bytes     new bytes     delta
BenchmarkSimpleUserDecodeStruct-8                               64            64            +0.00%
BenchmarkSimpleUserDecodeStructParallel-8                       64            64            +0.00%
BenchmarkSimpleUserEncodeStruct-8                               549           485           -11.66%
BenchmarkSimpleUserEncodeStructParallel-8                       549           485           -11.66%
BenchmarkPrimitivesDecodeStructAllPrimitivesTypes-8             96            96            +0.00%
BenchmarkPrimitivesDecodeStructAllPrimitivesTypesParallel-8     96            96            +0.00%
BenchmarkPrimitivesEncodeStructAllPrimitivesTypes-8             3073          3009          -2.08%
BenchmarkPrimitivesEncodeStructAllPrimitivesTypesParallel-8     3072          3010          -2.02%
BenchmarkComplexArrayDecodeStructAllTypes-8                     2289          2257          -1.40%
BenchmarkComplexArrayDecodeStructAllTypesParallel-8             2291          2257          -1.48%
BenchmarkComplexArrayEncodeStructAllTypes-8                     7351          7288          -0.86%
BenchmarkComplexArrayEncodeStructAllTypesParallel-8             7351          7290          -0.83%
BenchmarkComplexMapDecodeStructAllTypes-8                       5338          5306          -0.60%
BenchmarkComplexMapDecodeStructAllTypesParallel-8               5342          5308          -0.64%
BenchmarkComplexMapEncodeStructAllTypes-8                       7161          7100          -0.85%
BenchmarkComplexMapEncodeStructAllTypesParallel-8               7161          7099          -0.87%
BenchmarkDecodeNestedStruct-8                                   416           384           -7.69%
BenchmarkDecodeNestedStructParallel-8                           416           384           -7.69%
BenchmarkEncodeNestedStruct-8                                   768           704           -8.33%
BenchmarkEncodeNestedStructParallel-8                           768           704           -8.33%

Release 2.0.0

26 Jul 14:27
Compare
Choose a tag to compare

What's New in 2.0.0?

  • form now supports Decoding and Encoding of almost any type, not just structs. for #6
    eg.
// example url.Values
values := map[string][]string{ "val1", "val2" }

var arr []string

d.Decode(&arr, values)

Thanks @themihai for suggesting #6 and questioning #7

Any Fixes?

  • Corrected a bug where when decoding non indexed array values into an array with existing values was overwriting the current values instead of appending to the array, this has been corrected. ( Don't worry too much, most people won't have been using a pre-filled array )