]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blob - vendor/github.com/google/go-cmp/cmp/unsafe_reflect.go
Upgrade to 0.12
[github/fretlink/terraform-provider-statuscake.git] / vendor / github.com / google / go-cmp / cmp / unsafe_reflect.go
1 // Copyright 2017, The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE.md file.
4
5 // +build !purego,!appengine,!js
6
7 package cmp
8
9 import (
10 "reflect"
11 "unsafe"
12 )
13
14 const supportAllowUnexported = true
15
16 // unsafeRetrieveField uses unsafe to forcibly retrieve any field from a struct
17 // such that the value has read-write permissions.
18 //
19 // The parent struct, v, must be addressable, while f must be a StructField
20 // describing the field to retrieve.
21 func unsafeRetrieveField(v reflect.Value, f reflect.StructField) reflect.Value {
22 return reflect.NewAt(f.Type, unsafe.Pointer(v.UnsafeAddr()+f.Offset)).Elem()
23 }