Reprint
Golang deep copying, THE RIGHT WAY :tm:
Install / Use
/learn @qdm12/ReprintREADME
Reprint
Reprint is a Go library to deep copy any object THE RIGHT WAY :tm:
Features
Unlike most libraries out there, this one deep copies by assigning new pointers to all data structures nested in a given object, hence doing it THE RIGHT WAY :tm:
It works with slices, arrays, maps, pointers, nested pointers, nils, structs (with unexported fields too), functions and channels.
Limits:
- Functions pointers are not changed but that's by design
- Channels buffered elements are not deep copied
Usage
go get -u github.com/qdm12/reprint
You can check out Golang Playground and activate Imports at the top, or read this:
package main
import (
"fmt"
"github.com/qdm12/reprint"
)
func main() {
one := 1
two := 2
type myType struct{ A *int }
// reprint.FromTo usage:
var x, y myType
x.A = &one
reprint.FromTo(&x, &y) // you can check the error returned also
y.A = &two
fmt.Println(x.A, *x.A) // 0xc0000a0010 1
fmt.Println(y.A, *y.A) // 0xc0000a0018 2
// reprint.This usage:
x2 := myType{&one}
out := reprint.This(x2)
y2 := out.(myType)
y2.A = &two
fmt.Println(x2.A, *x2.A) // 0xc0000a0010 1
fmt.Println(y2.A, *y2.A) // 0xc0000a0018 2
}
Development
- Install Docker
- On Windows, share a drive with Docker Desktop and have the project on that partition
- On OSX, share your project directory with Docker Desktop
- With Visual Studio Code, install the remote containers extension
- In Visual Studio Code, press on
F1and selectRemote-Containers: Open Folder in Container... - Your dev environment is ready to go!... and it's running in a container :+1:
TODOs
- (Research) deep copy elements currently in channel
- Race conditions
- Pause channel?
- Polish
FromTo- Initialize copy to copy's type if it's a typed nil
- Initialize copy to original's type if it's an untyped nil
- Returns typed nil instead of untyped nil if original is a nil pointer (typed)
forceCopyValuemight not be needed
Related Skills
node-connect
347.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
xurl
347.0kA CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.
frontend-design
107.8kCreate 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
347.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).

