Skip to content

Releases: devfeel/mapper

feat(mapper): add generic MapDirect APIs - version 0.8

12 Mar 14:52
51bc51d

Choose a tag to compare

🚀 Version 0.8

⚡ Performance Optimization

  • MapDirect 系列函数 - 新增函数式泛型 API,带字段映射缓存
方法 旧版本 新版本 提升
单次映射 3,897 ns/op 556 ns/op 7x
批量映射 (100条) 452,718 ns/op 59,185 ns/op 7.6x
内存占用 400 B/op 272 B/op -32%
内存分配 42 allocs/op 4 allocs/op -90%

✨ New APIs

  • MapDirect[From, To](from From) To - 直接返回映射结果
  • MapDirectPtr[From, To](from *From) *To - 指针版本
  • MapDirectSlice[From, To](from []From) []To - 批量映射
  • MapDirectPtrSlice[From, To](from []*From) []*To - 指针批量
  • SafeMapDirect[From, To](from From) (To, error) - 带错误处理
  • SafeMapDirectSlice[From, To](from []From) ([]To, error) - 批量安全映射

🧪 Improvements

  • 新增 Benchmark 测试用例
  • 新增 example/func 使用示例

🔴 Breaking Changes

  • 移除已废弃的 mapper_generic.go / mapper_generic_test.go
  • 移除已废弃的 example/generic

Feature: Implement variable arguments based on NewMapper for flexible configuration settings when you init mapper

06 Sep 02:32

Choose a tag to compare

Version 0.7.14

  • Feature: Implement variable arguments based on NewMapper for flexible configuration settings when you init mapper.
  • Feature: Add Setting struct used to Config mapper
  • you can use like this:
  // Default Setting:
  // EnabledTypeChecking:      false,
  // EnabledMapperStructField: true,
  // EnabledAutoTypeConvert:   true,
  // EnabledMapperTag:         true,
  // EnabledJsonTag:           true,
  // EnabledCustomTag:         false,
  // EnableFieldIgnoreTag:     false,
  
  /// When you use default setting
  NewMapper()
  
  /// When you will change some setting
  NewMapper(CTypeChecking(true), CCustomTagName("-"))
  • 2024-09-06 19:00 in ShangHai

Full Changelog: v0.7.13...v0.7.14

Feature: Added the "composite-field" tag to mapping composite fields

15 Apr 11:25

Choose a tag to compare

Version 0.7.13

  • Feature: Added the "composite-field" tag to continue expanding and searching for corresponding field mappings when encountering composite fields in a Struct. Currently, only one level of expansion is supported.
  • Tips: Thanks to @naeemaei for issue #39
  • For my birthday!
  • you can use like this:
  // Base model
  type BaseModel struct {
      Id    int `json:"id"`
  }
  
  // Country model
  type Country struct {
      BaseModel `json:"composite-field"`
      Name      string `json:"name"`
  }
  • 2023-04-15 19:00 in ShangHai

BugFix: remove go mod file.

20 Apr 12:17
f14f3f9

Choose a tag to compare

Version 0.7.10

  • BugFix: remove go mod file.
  • 2022-04-20 20:00 in ShangHai

add feature flag for ignore tag

20 Apr 11:58
e0c28cc

Choose a tag to compare

Version 0.7.9

  • Feature: add feature flag for ignore tag.
  • Tips: about "-" we keep default behavior as previous version by default, which is use field name as key when mapping structure.
  • Tips: now you can use SetEnableFieldIgnoreTag function to enable this flag right now
  • 2022-04-17 21:00 in ShangHai

Refactor: use mapperObject refactored the static version implementation

16 Apr 06:07
4a27752

Choose a tag to compare

Version 0.7.8

  • Refactor: use mapperObject refactored the static version implementation.
  • 2022-04-16 10:00 in ShangHai

thanks @devfeel

add object-oriented api for mapper

15 Apr 16:05
28d634f

Choose a tag to compare

Pre-release

feature:

  • add object-oriented API for mapper which allow users to change lots of switch dynamically by calling SetEnabledMapperTag, SetEnabledJsonTag, and so on

thanks @shyandsy

add SetEnabledMapperTag and SetEnabledJsonTag

15 Apr 05:43
afed01d

Choose a tag to compare

Version 0.7.6

  • Feature: add SetEnabledMapperTag to set enabled flag for 'Mapper' tag check
  • Feature: add SetEnabledJsonTag to set enabled flag for 'Json' tag check
  • Ops: add some test cases
  • Tips: Thanks to @aeramu for issue #12
  • 2021-10-19 12:00 in ShangHai

Support for *[] to *[] and definitive error messages

26 Jan 05:33

Choose a tag to compare

Version 0.7.5

  • Feature: Support for *[] to *[] with MapperSlice
  • Ops: Definitive error messages
  • Tips: Merge pull request #9 from MrWormHole/master, Thanks to @mrwormhole
  • 2021-01-26 12:00 in ShangHai

add MapToSlice and support mapper struct to map

07 Jun 01:50

Choose a tag to compare

Version 0.7.4

  • Feature: AutoMapper&Mapper support mapper struct to map[string]interface{}
  • Feature: add MapToSlice to mapper from map[string]interface{} to a slice of any type's ptr
  • Refactor: set MapperMapSlice to Deprecated, will remove on v1.0
  • 2020-06-07 16:00 in ShangHai