1
0
mirror of https://github.com/golang/go synced 2024-11-18 13:24:39 -07:00
go/internal/typesinternal/types.go
Matthew Dempsky 51e3d70dba go/packages: use go115UsesCgo instead of UsesCgo
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>
2020-06-10 21:22:23 +00:00

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
}