github.com/huandu/go-clone v1.4.0
GitHub Actions workflow definition pathGo module source archive layout
SHA-2566af4d9cf892564e63945a0ff2e05214786a3a6a71a5aad2219cbd3cf4e85cd5e
MaleculeH(Db₂)Md₂(BkPa)
Evidence
⋯4 lines
9 "fmt"
10 "reflect"
11 "unsafe"
12)
13
14// Clone recursively deep clone v to a new value.
15// It assumes that there is no pointer cycle in v,
16// e.g. v has a point …
⋯5 lines
33 }
34
35 val := reflect.ValueOf(v)
36 cloned := noState.clone(val)
37 return cloned.Interface()
⋯4 lines
106:3… nc (state *cloneState) copyArray(src, nv reflect.Value) {
107 p := unsafe.Pointer(nv.Pointer()) // dst must be a Ptr.
108 dst := nv.Elem()
109 num := src.Len()
110
111 if isScalar(src.Type().Elem().Kind()) {
112 shadowCopy( …
⋯10 lines
11 "sync/atomic"
12 "time"
13 "unsafe"
14)
15
⋯5 lines
21func init() {
22 // Some well-known scalar-like structs.
23 MarkAsScalar(reflect.TypeOf(time.Time{}))
24 MarkAsScalar(reflect.TypeOf(reflect.Value{}))
25
26 // Special case for elliptic.Curve which is used by TLS ECC certificate.
27 // Package crypto/tls uses elliptic.Curve …
1package clone
2
3import (
4 "reflect"
5 "unsafe"
6)
7
8const sizeOfPointers = unsafe.Sizeof((interface{})(0)) / unsafe.Sizeof(uintptr(0))
9
10// interfaceData is the underlying data of an interface.
11// As the reflect.Value's interfaceData method is deprecated,
12// it may be broken in any Go release.
13// It's better to create a custom to hold the data.
⋯13 lines
27 fields := t.NumField()
28
29 for i := 0; i < fields; i++ {
30 field := t.Field(i)
31
⋯11 lines
43
44// parseReflectValue returns the underlying interface data in a reflect value.
45// It assumes that v is an interface value.
46func parseReflectValue(v reflect.Value) interfaceData {
47 pv := (unsafe.Pointer)(uintptr(unsafe.Pointer(&v)) + reflectValuePtrOffset)
48 ptr := *(*unsafe.Pointer)(pv)
Showing the top 5 files — 4 more files (11 regions) not shown.
No evidence locations were recorded for this file. Raw result