deepcopy

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2025 License: Apache-2.0 Imports: 0 Imported by: 0

README

The deriveDeepCopy function is a maintainable and fast way to implement fast deep copy functions.

Given the following input:

package deepcopy

type MyStruct struct {
	Int64     int64
	StringPtr *string
}

func (m *MyStruct) Clone() *MyStruct {
	if m == nil {
		return nil
	}
	n := &MyStruct{}
	deriveDeepCopy(n, m)
	return n
}

goderive will generate the following code:

// Code generated by goderive DO NOT EDIT.

package deepcopy

// deriveDeepCopy recursively copies the contents of src into dst.
func deriveDeepCopy(dst, src *MyStruct) {
	dst.Int64 = src.Int64
	if src.StringPtr == nil {
		dst.StringPtr = nil
	} else {
		dst.StringPtr = new(string)
		*dst.StringPtr = *src.StringPtr
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MyStruct

type MyStruct struct {
	Int64     int64
	StringPtr *string
}

func (*MyStruct) Clone

func (m *MyStruct) Clone() *MyStruct

Jump to

Keyboard shortcuts

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