Help us shape the future of Go! Take the 2026 Go Developer Survey

deepcopy

package module
v0.0.0-...-9e9fb5e Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2018 License: MIT Imports: 2 Imported by: 0

README

deepCopy

GoDocBuild Status

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

Usage

cpy := deepcopy.Copy(orig)

Tags

The following struct tags is supported:

type A struct {
    Field1 SomeType  `deepcopy:"-"` // skip, will have zero-value in copy
    Field2 *SomeType `deepcopy:"="` // treat like with "=" assignment operator
}

Specifically the = tag is usable when you want to copy a struct containing something like *sync.Mutex or *os.File and don't want it to be deeply copied but simply assigned.

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{}) 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.

func Iface

func Iface(iface interface{}) interface{}

Iface is an alias to Copy; this exists for backwards compatibility reasons.

Types

type Interface

type Interface interface {
	DeepCopy() interface{}
}

Interface for delegating copy process to type

Jump to

Keyboard shortcuts

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