Releases: devfeel/mapper
Releases · devfeel/mapper
feat(mapper): add generic MapDirect APIs - version 0.8
🚀 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
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
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.
Version 0.7.10
- BugFix: remove go mod file.
- 2022-04-20 20:00 in ShangHai
add feature flag for ignore tag
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
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
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
Support for *[] to *[] and definitive error messages
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
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