Skip to content
/ gref Public

gref is a utility library in Golang that utilizes reflection for data assignment. The main function is to assign values between two parameters, such as two different structs.

License

Notifications You must be signed in to change notification settings

zy1024/gref

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gref

gref is a utility library in Golang that utilizes reflection for data assignment. The main function is to assign values between two parameters, such as two different structs.

Install

go get github.com/zy1024/gref

Document Language : English, 中文.

Features

1. Copy

The Copy(src,dst) function requires two pointers, such as pointers to structs or slices. It will use reflection to assign the value of src to dst. The assignment of structs is based on matching field names, and only non-empty fields in dst will be assigned.

Support type

Support for basic data types, structs, Pointers, slices.

Operating efficiency

More efficient than traditional json.Marshal and json.Unmarshal methods. With the same data, the efficiency is about 3-4 times.

Example

The sample code can be seen in the TestCopy method in example_test.go.

Version

1.3.0

Official release, supporting assignment operations for structs, pointers, slices, and basic data types.

Next Development Steps

  1. Add support for other types, such as channel and map.

About

gref is a utility library in Golang that utilizes reflection for data assignment. The main function is to assign values between two parameters, such as two different structs.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages