Skip to content

Releases: soranoba/henge

v2.1.0

09 Apr 06:50
ec264a9
Compare
Choose a tag to compare

New Features

We have added callbacks for performing additional processing during struct conversion.
Previously, when converting structs that across packages, callbacks could only be written for one of conversion. With this update, you can now write callbacks for both.

Please refer to BeforeConvertFromCallback, BeforeConvertToCallback, AfterConvertFromCallback, and AfterConvertToCallback for more details.

Deprecated

Old New
BeforeConvertCallback BeforeConvertFromCallback
AfterConvertCallback AfterConvertFromCallback

v2.0.0 (Enhanced map conversion)

10 May 08:49
eeb059a
Compare
Choose a tag to compare

Breaking Changes

Behavior

src := map[string]interface{}{
	"a": map[string]interface{}{"a.1": "a.1"},
}
var dst map[string]interface{}
henge.New(src).Map().Convert(&dst)

v1: Type of dst["a"] is map[string]interface{}
v2: Type of dst["b"] is map[interface{}]interface{}

This means that it may be converted to a non-json-marshalable type from json-marshalable type.
You should replace it with the following method if necessary.

henge.New(src).JSONObject().Convert(&dst)
henge.New(src, henge.WithMapMaxDepth(0)).Convert(&dst)

Interface changes

type BeforeCallback interface {
-	BeforeConvert(src interface{}, converter Converter) error
+	BeforeConvert(src interface{}, store InstanceStore) error
}

type AfterCallback interface {
-	AfterConvert(src interface{}, converter Converter) error
+	AfterConvert(src interface{}, store InstanceStore) error
}

Renames

v1 v2
type func(*ConverterOpts) ConverterOption
interface Converter InstanceStore
method ValueConverter.JSONMap() ValueConverter.JSONObject()
struct JSONMapConverter JSONObjectConverter
method ValueConverter. FloatrPtr() ValueConverter.FloatPtr()

New Features

New Conversions

  • JSONValue
  • JSONArray
  • JSONObject

New Options

  • WithSliceValueConverter
  • WithMapKeyConverter
  • WithMapValueConverter
  • WithMapStructValueConverter
  • WithMapTimeValueStringConverter

Bug fixes

  • #8 : ValueConverter.Value() returns incorrect value when srcValue is nil.

v1.2.1

27 Jan 08:50
1ed8295
Compare
Choose a tag to compare
  • #7 Fixed copy of embedded field not working properly

v1.2.0

26 Jan 07:15
5f8330d
Compare
Choose a tag to compare
  • #6 add ToBool, ToBoolPtr
  • #4 Add syntax sugars. (e.g. ToString)
  • #5 Fix typo Float[r]Ptr

v1.1.0

22 Jan 08:23
44e9d4b
Compare
Choose a tag to compare
  • #2 Can specify rounding method from float to integer

v1.0.1

19 Jan 00:34
e232cfa
Compare
Choose a tag to compare
  • #1 Fix that ConvertError crash and has incorrect value.

v1.0.0

10 Jan 05:31
Compare
Choose a tag to compare

Major released.