cp

package
v0.0.0-...-a56dbdc Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2018 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Anything = generic.DefineFunc("CopyAnything(err *error, dst DT, src ST)").
	Param("DT", "the dst type to copy into").
	Param("ST", "the src type to copy from").
	Generators(
		"dispatch", dispatch,
		"hasErrorField", func(typ reflect.Type) bool {
			if typ.Kind() != reflect.Ptr {
				return false
			}
			typ = typ.Elem()
			if typ.Kind() != reflect.Struct {
				return false
			}
			_, found := typ.FieldByName("Error")
			return found
		}).
	ImportPackage("io").
	Declare("var ioEOF = io.EOF").
	Source(`
{{ $tmpl := dispatch .DT .ST }}
{{ $cp := expand $tmpl "DT" .DT "ST" .ST }}
{{$cp}}(err, dst, src)
{{ if hasErrorField .ST }}
if src.Error != nil && src.Error != ioEOF {
	*err = src.Error
}
{{ end }}
{{ if hasErrorField .DT }}
if dst.Error != nil {
	*err = dst.Error
}
{{ end }}
`)
View Source
var AnythingForPlz = generic.DefineFunc("CopyAnythingForPlz(theCopyDynamically CT, dst interface{}, src interface{}) error").
	Param("DT", "the dst type to copy into").
	Param("ST", "the src type to copy from").
	Param("CT", "type of copy dynamically function").
	ImportFunc(Anything).
	Declare("var copyDynamically func(interface{}, interface{}) error").
	Source(`
{{ $cp := expand "CopyAnything" "DT" .DT "ST" .ST }}
copyDynamically = theCopyDynamically
var err error
{{$cp}}(&err, dst.({{.DT|name}}), src.({{.ST|name}}))
return err`)
View Source
var Dispatchers = []func(dstType, srcType reflect.Type) string{}

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
tests

Jump to

Keyboard shortcuts

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