This package provides a generic way of deep copying Go objects

Overview

Package for copying Go values

This package provides a generic way of deep copying Go objects. It is designed with performance in mind and is suitable for production use.

This is not an official Google product.

WARNING: This package's API is currently unstable and may change without warning. If this matters to you, you should wait until version 1.0 is released before using it.

Install

go get -u github.com/google/go-cpy/cpy
You might also like...
Gopify is a simple package for developing Shopify applications in Go.

Gopify Gopify is a simple package for developing Shopify applications in Go. Table of Contents Usage Oauth Start oauth process Oauth callback API call

Golang's Context package examples

Golang's Context package examples To run the server: go run . api-up The server will be started in port 3001 In the file "router.go" of the folder "ap

⚡Simple cors middleware package for minima
⚡Simple cors middleware package for minima

This is package is wrapper based on rs/cors package made for minima. Geting Started Install the package using go get github.com/gominima/cors and call

This library implements the pub/sub pattern in a generic way. It uses Go's generic types to declare the type of the event.

observer This library implements the pub/sub pattern in a generic way. It uses Go's generic types to declare the type of the event. Usage go get githu

Extremely flexible golang deep comparison, extends the go testing package, tests HTTP APIs and provides tests suite
Extremely flexible golang deep comparison, extends the go testing package, tests HTTP APIs and provides tests suite

go-testdeep Extremely flexible golang deep comparison, extends the go testing package. Latest news Synopsis Description Installation Functions Availab

vjson is a Go package that helps to validate JSON objects in a declarative way.

vjson vjson is a Go package that helps to validate JSON objects in a declarative way. Getting Started Installing For installing vjson, use command bel

pr-bullet is a tool for copying pull request to multiple repositories.

pr-bullet pr-bullet is a tool for copying pull request to multiple repositories. Usage First, create original pull request ( ex. https://github.com/k1

Desktop application to download videos and playlists from youtube by simply copying its url.
Desktop application to download videos and playlists from youtube by simply copying its url.

tubemp3 Desktop application to download videos and playlists from youtube by simply copying its url. You just need to run tubemp3 and copy (CTRL + C)

tmux-fastcopy aids in copying of text in a tmux pane with ease.
tmux-fastcopy aids in copying of text in a tmux pane with ease.

tmux-fastcopy tmux-fastcopy aids in copying of text in a tmux pane with ease. How? When you invoke tmux-fastcopy, it inspects your tmux pane and overl

Provider-generic-workflows - A generic provider which uses argo workflows to define the backend actions.

provider-generic-workflows provider-generic-workflows is a generic provider which uses argo workflows for managing the external resource. This will re

Go-generic-unboxing - A quick ready to ship demo for go generic using the official example

Go generic This repo contain basic demo for installing and running go1.18beta1 v

Generic - Golang generic example

泛型 场景 假设需要写一个列表总数计算的函数,根据不同数据类型,我们可能分别要写 SumInts(data []int),SumFloats(data []fl

fonet is a deep neural network package for Go.

fonet fonet is a deep neural network package for Go. It's mainly created because I wanted to learn about neural networks and create my own package. I'

Extremely flexible golang deep comparison, extends the go testing package and tests HTTP APIs
Extremely flexible golang deep comparison, extends the go testing package and tests HTTP APIs

go-testdeep Extremely flexible golang deep comparison, extends the go testing package. Latest news Synopsis Description Installation Functions Availab

Package create provides a generic option pattern for creating new values of any type

create Package create provides a generic option pattern for creating new values

Package iter provides generic, lazy iterators, functions for producing them from primitive types, as well as functions and methods for transforming and consuming them.

iter Package iter provides generic, lazy iterators, functions for producing them from primitive types, as well as functions and methods for transformi

httpstream provides HTTP handlers for simultaneous streaming uploads and downloads of objects, as well as persistence and a standalone server.

httpfstream httpfstream provides HTTP handlers for simultaneous streaming uploads and downloads of files, as well as persistence and a standalone serv

Tapestry is an underlying distributed object location and retrieval system (DOLR) which can be used to store and locate objects. This distributed system provides an interface for storing and retrieving key-value pairs.

Tapestry This project implements Tapestry, an underlying distributed object location and retrieval system (DOLR) which can be used to store and locate

Comments
  • Decide between cpy.Machine and cpy.Copier

    Decide between cpy.Machine and cpy.Copier

    cpy.Machine avoids repetition and sounds like a photocopier. cpy.Copier is fairly conventional Go naming.

    One last chance to pick between the two before 1.0.

    opened by neild 1
  • Decide on use of type parameters

    Decide on use of type parameters

    We could use type parameters in the cpy API in a few places.

    func Func[T any](fn func(T) T) Option { ... }
    

    Func could be parameterized on the copied type, ensuring that the copy function has the right number of parameters and that the input and output match. However, we cannot fully express the constraints on T using 1.18 type parameters: I do not believe there is any way to indicate that T may be an interface type but may not be a channel.

    func Shallow[T any]() Option { ... }
    

    Shallow could also be type parameterized, passing the type to shallow copy rather than a prototype value of that type. The limitations on expressing the constraints on T still apply.

    Unlike Func, we cannot infer a type parameter for a call to Shallow, so we would need to provide functions with different names for pre- and post- generics versions of Go.

    func Copy[T any](c *Copier, v T) T { ... }
    

    We cannot parameterize the Copier.Copy method, but we could provide a Copy function that avoids the need to use a type assertion to recover the type of the new value.

    Unlike the changes to Func and Shallow, this does arguably make the package API simpler to use:

    b := copier.Copy(a).(T)  // need to type assert back to the type of a
    b := cpy.Copy(copier, a) // no type assertion needed
    
    opened by neild 1
  • Document requirement for IgnoreAllUnexported

    Document requirement for IgnoreAllUnexported

    cpy.New currently requires that the user pass cpy.IgnoreAllUnexported. Document this requirement, or change it.

    We require that the user specify this option because it isn't clear what the correct default handling of unexported fields is. (See TODO in the code detailing various possibilities.) If we're confident that there is no natural default and the user will always be required to pick a behavior, perhaps we should promote this option to the function signature:

    type Mode int
    
    const (
      IgnoreAllUnexported Mode = iota
    )
    
    func New(mode Mode, opts ...Option) *Machine { ... }
    
    opened by neild 0
Owner
Google
Google ❤️ Open Source
Google
A quick and easy way to setup a RESTful JSON API

Go-Json-Rest A quick and easy way to setup a RESTful JSON API Go-Json-Rest is a thin layer on top of net/http that helps building RESTful JSON APIs ea

Antoine Imbert 3.5k Jan 3, 2023
Include files in your binary the easy way

New Projects should use the official embed package instead, which was added in go 1.16. binclude binclude is a tool for including static files into Go

null 283 Dec 18, 2022
This library provides a simple framework of microservice, which includes a configurator, a logger, metrics, and of course the handler

Microservice The framework for the creation of microservices, written in Golang. (note: http microservice) Architecture microservice includes: handle

Eduard 109 Dec 30, 2022
The Direct Route GO SDK provides a thin wrapper around the Direct Route API for sending private transactions

Direct Route Go SDK The Direct Route GO SDK provides a thin wrapper around the D

null 31 Dec 8, 2022
RPC Framework abstraction layer. Provides foundation of the RonyDesc to generate RPC server/client codes.

RonyKit RonyKit provides the abstraction layer for creating a cluster aware API server. By defining separate components for each task, you are almost

Ronak Software Group 5 Dec 15, 2022
Package macaron is a high productive and modular web framework in Go.

Macaron Package macaron is a high productive and modular web framework in Go. Getting Started The minimum requirement of Go is 1.6. To install Macaron

Macaron 3.3k Jan 2, 2023
package for building REST-style Web Services using Go

go-restful package for building REST-style Web Services using Google Go Code examples using v3 REST asks developers to use HTTP methods explicitly and

Ernest Micklei 4.7k Jan 1, 2023
Go-app is a package to build progressive web apps with Go programming language and WebAssembly.

Go-app is a package to build progressive web apps with Go programming language and WebAssembly.

Maxence Charriere 6.7k Dec 30, 2022
A very simple and powerful package for making REST requests with very little effort

Welcome to KRest KRest stands for Keep it simple REST Package. It's a very simple and powerful package wrapper over the standard http package for maki

Vinícius Garcia 6 Dec 1, 2022