menu
techminis

A naukri.com initiative

google-web-stories
Home

>

Programming News

>

Introducin...
source image

Medium

1w

read

41

img
dot

Image Credit: Medium

Introducing go-mapper: a simple struct mapping package for Go inspired by .NET’s AutoMapper

  • The go-mapper package simplifies struct mapping in Go by taking inspiration from .NET's AutoMapper.
  • It leverages Go generics and reflection to automate field mapping between structs with matching names and types.
  • Custom mapping rules can be defined for fields that require specific transformations, such as hashing passwords.
  • Mapping profiles can be created using a fluent API to configure data transformations like password hashing.
  • An example scenario involves transforming a Password field from a user creation DTO to a PasswordHash in the domain model.
  • go-mapper allows for copying data from the DTO with the password correctly hashed based on custom logic.
  • The package is open source, accessible on GitHub at https://github.com/davitostes/go-mapper.
  • The repository provides examples, basic documentation, and encourages contributions from the community.
  • For those working with Go and seeking to streamline struct mapping and reduce boilerplate, go-mapper is recommended.

Read Full Article

like

2 Likes

For uninterrupted reading, download the app