mirror of
https://github.com/golang/go
synced 2024-11-05 15:06:09 -07:00
51e3d70dba
x/tools half of golang.org/cl/237417. Updates #16623. Updates #39072. Change-Id: Ic31c2cf64dc1b71b70912b9641cf468f60d116f8 Reviewed-on: https://go-review.googlesource.com/c/tools/+/237418 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com>
29 lines
516 B
Go
29 lines
516 B
Go
// Copyright 2020 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package typesinternal
|
|
|
|
import (
|
|
"go/types"
|
|
"reflect"
|
|
"unsafe"
|
|
)
|
|
|
|
func SetUsesCgo(conf *types.Config) bool {
|
|
v := reflect.ValueOf(conf).Elem()
|
|
|
|
f := v.FieldByName("go115UsesCgo")
|
|
if !f.IsValid() {
|
|
f = v.FieldByName("UsesCgo")
|
|
if !f.IsValid() {
|
|
return false
|
|
}
|
|
}
|
|
|
|
addr := unsafe.Pointer(f.UnsafeAddr())
|
|
*(*bool)(addr) = true
|
|
|
|
return true
|
|
}
|