-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]> Reviewed-by: Heschi Kreinick <[email protected]>
- Loading branch information
Showing
4 changed files
with
34 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// 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 | ||
} |