https://github.com/unsafe-risk/deecpy
Deecpy, The DeepCopy Library
https://github.com/unsafe-risk/deecpy
clone deepcopy duplicate go golang golang-deepcopy struct
Last synced: about 1 year ago
JSON representation
Deecpy, The DeepCopy Library
- Host: GitHub
- URL: https://github.com/unsafe-risk/deecpy
- Owner: unsafe-risk
- License: unlicense
- Created: 2022-07-07T06:40:35.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-11-14T17:30:16.000Z (over 1 year ago)
- Last Synced: 2025-05-07T22:44:29.959Z (about 1 year ago)
- Topics: clone, deepcopy, duplicate, go, golang, golang-deepcopy, struct
- Language: Go
- Homepage:
- Size: 46.9 KB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://pkg.go.dev/v8.run/go/deecpy)
[](https://github.com/unsafe-risk/deecpy/actions/workflows/go_test.yml)
[](https://app.codecov.io/gh/unsafe-risk/deecpy)
[](https://pkg.go.dev/v8.run/go/deecpy?tab=licenses)
# Deecpy
**Deecpy**, The DeepCopy Library
# Example
```go
package main
import (
"fmt"
"v8.run/go/deecpy"
)
// func deecpy.Copy[T any](dst, src *T) error
// func deecpy.Duplicate[T any](src T) (T, error)
type Person struct {
Name string
Age int
id ID
}
type ID struct {
UUID string
email string
}
var john = Person{Name: "John", Age: 30, id: ID{UUID: "123", email: "john@example.com"}}
var jane = Person{Name: "Jane", Age: 25, id: ID{UUID: "456", email: "jane@example.com"}}
func main() {
var john_copy Person
err := deecpy.Copy(&john_copy, &john)
if err != nil {
panic(err)
}
fmt.Println("john:", john)
fmt.Println("john_copy:", john_copy)
jane_copy, err := deecpy.Duplicate(jane)
if err != nil {
panic(err)
}
fmt.Println("jane:", jane)
fmt.Println("jane_copy:", jane_copy)
}
```
[***Go Playground***](https://go.dev/play/p/4Kc5gPCaebk)