deepcopy

package module
v0.0.0-...-5d6df38 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2019 License: MIT Imports: 2 Imported by: 2

README

deepCopy

GoDoc

DeepCopy makes deep copies of things: unexported field values are not copied.

It also allows for returning a pointer to the copied object, which is useful for using the copied object with more reflection operations.

This implementation of deepcopy is not as optimized as some other implementations (e.g. mitchellh/copystructure). We also don't provide benchmarks.

The tests probably don't work as of now because of the addition of the options.

Usage

cpy := deepcopy.Copy(orig, Options{ReturnPointer:false})

Documentation

Overview

deepcopy makes deep copies of things. A standard copy will copy the pointers: deep copy copies the values pointed to. Unexported field values are not copied.

Copyright (c)2014-2016, Joel Scoble (github.com/mohae), all rights reserved. License: MIT, for more details check the included LICENSE file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy

func Copy(src interface{}, opts Options) interface{}

Copy creates a deep copy of whatever is passed to it and returns the copy in an interface{}. The returned value will need to be asserted to the correct type.

Types

type Interface

type Interface interface {
	DeepCopy() interface{}
}

Interface for delegating copy process to type

type Options

type Options struct {
	// ReturnPointer determines whether Copy() should return the pointer to the newly copied object or the object itself
	ReturnPointer bool
}

Jump to

Keyboard shortcuts

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