Gomapper
An auto mapping tool for Golang DTOs
Install / Use
/learn @Trendyol/GomapperREADME
gomapper
An auto mapping tool for Golang DTOs. Basically it maps DTOs by field names.
(Originally inspired by https://github.com/stroiman/go-automapper)
Important!
Please be very careful when using this tool for deep copying of objects. This tool is not intended for deep copying. While moving the source to the destination, it carries the same reference (pointer) types only by reference. It would only make sense to use it as a data transfer object (DTO) between software layers.
Example:
// Declare your types:
type Location struct {
Name string
zone []string
}
type Source struct {
Ui64 uint64
i64 int64
Location Location
}
type Destination struct {
Ui64 uint64
i64 int64
Location *Location
}
// Declare your variables:
src := Source{
Ui64: 123,
i64: 321,
Location: Location{
Name: "abc",
zone: []string{"k", "l", "m"},
},
}
dest := Destination{}
// Use Map function:
if err := gomapper.Map(src, &dest); err != nil {
// handle mapping error
}
// You will see i64 field in the dest object is equal to zero.
// Because private fields won't map until source
// and destination types are the same.
// (src and dest variables are two different types)
Related Skills
node-connect
351.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
351.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
351.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
