structmapper

command module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

README

structmapper

Features

  • mapper from struct to struct with same name
  • mapper from slice to slice
  • mapper from method to field with same name
package response

type User struct {
	ID int
	Mobile       string
	Level       int
	Name           string
	RegisterTime time.Time
}

package domain

import "time"

type User struct {
	ID int
	Mobile       string
	Level       int
	Name           string
	RegisterTime time.Time
}

//go:generate go run github.com/wizardshan/structmapper -toObject response.User -fromObject domain.User -moduleName examples

user_copy.go

package response

import "examples/domain"

func (response *User) Copy(domain domain.User) {
	/**************** mapper start ****************/
	response.ID = domain.ID
	response.Mobile = domain.Mobile
	response.Level = domain.Level
	response.Name = domain.Name
	response.RegisterTime = domain.RegisterTime

	/**************** mapper end  ****************/
}


Benchmarks

Benchmark name (1) (2) (3) (4)
BenchmarkMapper 1000000000 0.3679 ns/op 0 B/op 0 allocs/op
BenchmarkCopier 163282 6852 ns/op 3000 B/op 48 allocs/op

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL