Use apiextension v1

- upgrade from apiextension v1beta1 to v1
 - generate yaml manifest for crd intead of applying it at runtime
  - users will have to apply the manifest with kubectl
 - kg and kgctl log an error if the crd is not present
 - now validation should actually work

Signed-off-by: leonnicolas <leonloechner@gmx.de>
This commit is contained in:
leonnicolas
2021-06-14 09:08:46 +02:00
parent e272d725a5
commit 36643b77b4
584 changed files with 50911 additions and 55838 deletions

View File

@@ -96,6 +96,8 @@ func Of64(k Key, v uint64) Label { return Label{key: k, packed: v} }
// access should be done with the From method of the key.
func (t Label) Unpack64() uint64 { return t.packed }
type stringptr unsafe.Pointer
// OfString creates a new label from a key and a string.
// This method is for implementing new key types, label creation should
// normally be done with the Of method of the key.
@@ -104,7 +106,7 @@ func OfString(k Key, v string) Label {
return Label{
key: k,
packed: uint64(hdr.Len),
untyped: unsafe.Pointer(hdr.Data),
untyped: stringptr(hdr.Data),
}
}
@@ -115,9 +117,9 @@ func OfString(k Key, v string) Label {
func (t Label) UnpackString() string {
var v string
hdr := (*reflect.StringHeader)(unsafe.Pointer(&v))
hdr.Data = uintptr(t.untyped.(unsafe.Pointer))
hdr.Data = uintptr(t.untyped.(stringptr))
hdr.Len = int(t.packed)
return *(*string)(unsafe.Pointer(hdr))
return v
}
// Valid returns true if the Label is a valid one (it has a key).

View File

@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build freebsd || openbsd || netbsd
// +build freebsd openbsd netbsd
package fastwalk

View File

@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build (linux || darwin) && !appengine
// +build linux darwin
// +build !appengine

View File

@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build darwin || freebsd || openbsd || netbsd
// +build darwin freebsd openbsd netbsd
package fastwalk

View File

@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build linux
// +build !appengine
//go:build linux && !appengine
// +build linux,!appengine
package fastwalk

View File

@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build appengine || (!linux && !darwin && !freebsd && !openbsd && !netbsd)
// +build appengine !linux,!darwin,!freebsd,!openbsd,!netbsd
package fastwalk

View File

@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build (linux || darwin || freebsd || openbsd || netbsd) && !appengine
// +build linux darwin freebsd openbsd netbsd
// +build !appengine
@@ -21,7 +22,7 @@ const blockSize = 8 << 10
const unknownFileMode os.FileMode = os.ModeNamedPipe | os.ModeSocket | os.ModeDevice
func readDir(dirName string, fn func(dirName, entName string, typ os.FileMode) error) error {
fd, err := syscall.Open(dirName, 0, 0)
fd, err := open(dirName, 0, 0)
if err != nil {
return &os.PathError{Op: "open", Path: dirName, Err: err}
}
@@ -35,7 +36,7 @@ func readDir(dirName string, fn func(dirName, entName string, typ os.FileMode) e
for {
if bufp >= nbuf {
bufp = 0
nbuf, err = syscall.ReadDirent(fd, buf)
nbuf, err = readDirent(fd, buf)
if err != nil {
return os.NewSyscallError("readdirent", err)
}
@@ -126,3 +127,27 @@ func parseDirEnt(buf []byte) (consumed int, name string, typ os.FileMode) {
}
return
}
// According to https://golang.org/doc/go1.14#runtime
// A consequence of the implementation of preemption is that on Unix systems, including Linux and macOS
// systems, programs built with Go 1.14 will receive more signals than programs built with earlier releases.
//
// This causes syscall.Open and syscall.ReadDirent sometimes fail with EINTR errors.
// We need to retry in this case.
func open(path string, mode int, perm uint32) (fd int, err error) {
for {
fd, err := syscall.Open(path, mode, perm)
if err != syscall.EINTR {
return fd, err
}
}
}
func readDirent(fd int, buf []byte) (n int, err error) {
for {
nbuf, err := syscall.ReadDirent(fd, buf)
if err != syscall.EINTR {
return nbuf, err
}
}
}

View File

@@ -12,6 +12,7 @@ import (
"path/filepath"
"regexp"
"strings"
"time"
"golang.org/x/mod/semver"
)
@@ -19,11 +20,15 @@ import (
// ModuleJSON holds information about a module.
type ModuleJSON struct {
Path string // module path
Version string // module version
Versions []string // available module versions (with -versions)
Replace *ModuleJSON // replaced by this module
Time *time.Time // time version was created
Update *ModuleJSON // available update, if any (with -u)
Main bool // is this the main module?
Indirect bool // is this module only an indirect dependency of main module?
Dir string // directory holding files for this module, if any
GoMod string // path to go.mod file for this module, if any
GoMod string // path to go.mod file used when loading this module, if any
GoVersion string // go version used in module
}

View File

@@ -89,8 +89,10 @@ func (r *ModuleResolver) init() error {
err := r.initAllMods()
// We expect an error when running outside of a module with
// GO111MODULE=on. Other errors are fatal.
if err != nil && !strings.Contains(err.Error(), "working directory is not part of a module") {
return err
if err != nil {
if errMsg := err.Error(); !strings.Contains(errMsg, "working directory is not part of a module") && !strings.Contains(errMsg, "go.mod file not found") {
return err
}
}
}

View File

@@ -974,13 +974,29 @@ var stdlib = map[string][]string{
"DF_STATIC_TLS",
"DF_SYMBOLIC",
"DF_TEXTREL",
"DT_ADDRRNGHI",
"DT_ADDRRNGLO",
"DT_AUDIT",
"DT_AUXILIARY",
"DT_BIND_NOW",
"DT_CHECKSUM",
"DT_CONFIG",
"DT_DEBUG",
"DT_DEPAUDIT",
"DT_ENCODING",
"DT_FEATURE",
"DT_FILTER",
"DT_FINI",
"DT_FINI_ARRAY",
"DT_FINI_ARRAYSZ",
"DT_FLAGS",
"DT_FLAGS_1",
"DT_GNU_CONFLICT",
"DT_GNU_CONFLICTSZ",
"DT_GNU_HASH",
"DT_GNU_LIBLIST",
"DT_GNU_LIBLISTSZ",
"DT_GNU_PRELINKED",
"DT_HASH",
"DT_HIOS",
"DT_HIPROC",
@@ -990,28 +1006,100 @@ var stdlib = map[string][]string{
"DT_JMPREL",
"DT_LOOS",
"DT_LOPROC",
"DT_MIPS_AUX_DYNAMIC",
"DT_MIPS_BASE_ADDRESS",
"DT_MIPS_COMPACT_SIZE",
"DT_MIPS_CONFLICT",
"DT_MIPS_CONFLICTNO",
"DT_MIPS_CXX_FLAGS",
"DT_MIPS_DELTA_CLASS",
"DT_MIPS_DELTA_CLASSSYM",
"DT_MIPS_DELTA_CLASSSYM_NO",
"DT_MIPS_DELTA_CLASS_NO",
"DT_MIPS_DELTA_INSTANCE",
"DT_MIPS_DELTA_INSTANCE_NO",
"DT_MIPS_DELTA_RELOC",
"DT_MIPS_DELTA_RELOC_NO",
"DT_MIPS_DELTA_SYM",
"DT_MIPS_DELTA_SYM_NO",
"DT_MIPS_DYNSTR_ALIGN",
"DT_MIPS_FLAGS",
"DT_MIPS_GOTSYM",
"DT_MIPS_GP_VALUE",
"DT_MIPS_HIDDEN_GOTIDX",
"DT_MIPS_HIPAGENO",
"DT_MIPS_ICHECKSUM",
"DT_MIPS_INTERFACE",
"DT_MIPS_INTERFACE_SIZE",
"DT_MIPS_IVERSION",
"DT_MIPS_LIBLIST",
"DT_MIPS_LIBLISTNO",
"DT_MIPS_LOCALPAGE_GOTIDX",
"DT_MIPS_LOCAL_GOTIDX",
"DT_MIPS_LOCAL_GOTNO",
"DT_MIPS_MSYM",
"DT_MIPS_OPTIONS",
"DT_MIPS_PERF_SUFFIX",
"DT_MIPS_PIXIE_INIT",
"DT_MIPS_PLTGOT",
"DT_MIPS_PROTECTED_GOTIDX",
"DT_MIPS_RLD_MAP",
"DT_MIPS_RLD_MAP_REL",
"DT_MIPS_RLD_TEXT_RESOLVE_ADDR",
"DT_MIPS_RLD_VERSION",
"DT_MIPS_RWPLT",
"DT_MIPS_SYMBOL_LIB",
"DT_MIPS_SYMTABNO",
"DT_MIPS_TIME_STAMP",
"DT_MIPS_UNREFEXTNO",
"DT_MOVEENT",
"DT_MOVESZ",
"DT_MOVETAB",
"DT_NEEDED",
"DT_NULL",
"DT_PLTGOT",
"DT_PLTPAD",
"DT_PLTPADSZ",
"DT_PLTREL",
"DT_PLTRELSZ",
"DT_POSFLAG_1",
"DT_PPC64_GLINK",
"DT_PPC64_OPD",
"DT_PPC64_OPDSZ",
"DT_PPC64_OPT",
"DT_PPC_GOT",
"DT_PPC_OPT",
"DT_PREINIT_ARRAY",
"DT_PREINIT_ARRAYSZ",
"DT_REL",
"DT_RELA",
"DT_RELACOUNT",
"DT_RELAENT",
"DT_RELASZ",
"DT_RELCOUNT",
"DT_RELENT",
"DT_RELSZ",
"DT_RPATH",
"DT_RUNPATH",
"DT_SONAME",
"DT_SPARC_REGISTER",
"DT_STRSZ",
"DT_STRTAB",
"DT_SYMBOLIC",
"DT_SYMENT",
"DT_SYMINENT",
"DT_SYMINFO",
"DT_SYMINSZ",
"DT_SYMTAB",
"DT_SYMTAB_SHNDX",
"DT_TEXTREL",
"DT_TLSDESC_GOT",
"DT_TLSDESC_PLT",
"DT_USED",
"DT_VALRNGHI",
"DT_VALRNGLO",
"DT_VERDEF",
"DT_VERDEFNUM",
"DT_VERNEED",
"DT_VERNEEDNUM",
"DT_VERSYM",
@@ -1271,17 +1359,38 @@ var stdlib = map[string][]string{
"PF_R",
"PF_W",
"PF_X",
"PT_AARCH64_ARCHEXT",
"PT_AARCH64_UNWIND",
"PT_ARM_ARCHEXT",
"PT_ARM_EXIDX",
"PT_DYNAMIC",
"PT_GNU_EH_FRAME",
"PT_GNU_MBIND_HI",
"PT_GNU_MBIND_LO",
"PT_GNU_PROPERTY",
"PT_GNU_RELRO",
"PT_GNU_STACK",
"PT_HIOS",
"PT_HIPROC",
"PT_INTERP",
"PT_LOAD",
"PT_LOOS",
"PT_LOPROC",
"PT_MIPS_ABIFLAGS",
"PT_MIPS_OPTIONS",
"PT_MIPS_REGINFO",
"PT_MIPS_RTPROC",
"PT_NOTE",
"PT_NULL",
"PT_OPENBSD_BOOTDATA",
"PT_OPENBSD_RANDOMIZE",
"PT_OPENBSD_WXNEEDED",
"PT_PAX_FLAGS",
"PT_PHDR",
"PT_S390_PGSTE",
"PT_SHLIB",
"PT_SUNWSTACK",
"PT_SUNW_EH_FRAME",
"PT_TLS",
"Prog",
"Prog32",
@@ -2445,6 +2554,9 @@ var stdlib = map[string][]string{
"SectionHeader",
"Sym",
},
"embed": []string{
"FS",
},
"encoding": []string{
"BinaryMarshaler",
"BinaryUnmarshaler",
@@ -2680,6 +2792,7 @@ var stdlib = map[string][]string{
"FlagSet",
"Float64",
"Float64Var",
"Func",
"Getter",
"Int",
"Int64",
@@ -2853,6 +2966,18 @@ var stdlib = map[string][]string{
"Package",
"ToolDir",
},
"go/build/constraint": []string{
"AndExpr",
"Expr",
"IsGoBuild",
"IsPlusBuild",
"NotExpr",
"OrExpr",
"Parse",
"PlusBuildLines",
"SyntaxError",
"TagExpr",
},
"go/constant": []string{
"BinaryOp",
"BitLen",
@@ -3273,6 +3398,7 @@ var stdlib = map[string][]string{
"Must",
"New",
"OK",
"ParseFS",
"ParseFiles",
"ParseGlob",
"Srcset",
@@ -3432,6 +3558,7 @@ var stdlib = map[string][]string{
"Copy",
"CopyBuffer",
"CopyN",
"Discard",
"EOF",
"ErrClosedPipe",
"ErrNoProgress",
@@ -3443,12 +3570,15 @@ var stdlib = map[string][]string{
"MultiReader",
"MultiWriter",
"NewSectionReader",
"NopCloser",
"Pipe",
"PipeReader",
"PipeWriter",
"ReadAll",
"ReadAtLeast",
"ReadCloser",
"ReadFull",
"ReadSeekCloser",
"ReadSeeker",
"ReadWriteCloser",
"ReadWriteSeeker",
@@ -3472,6 +3602,49 @@ var stdlib = map[string][]string{
"WriterAt",
"WriterTo",
},
"io/fs": []string{
"DirEntry",
"ErrClosed",
"ErrExist",
"ErrInvalid",
"ErrNotExist",
"ErrPermission",
"FS",
"File",
"FileInfo",
"FileMode",
"Glob",
"GlobFS",
"ModeAppend",
"ModeCharDevice",
"ModeDevice",
"ModeDir",
"ModeExclusive",
"ModeIrregular",
"ModeNamedPipe",
"ModePerm",
"ModeSetgid",
"ModeSetuid",
"ModeSocket",
"ModeSticky",
"ModeSymlink",
"ModeTemporary",
"ModeType",
"PathError",
"ReadDir",
"ReadDirFS",
"ReadDirFile",
"ReadFile",
"ReadFileFS",
"SkipDir",
"Stat",
"StatFS",
"Sub",
"SubFS",
"ValidPath",
"WalkDir",
"WalkDirFunc",
},
"io/ioutil": []string{
"Discard",
"NopCloser",
@@ -3483,6 +3656,7 @@ var stdlib = map[string][]string{
"WriteFile",
},
"log": []string{
"Default",
"Fatal",
"Fatalf",
"Fatalln",
@@ -3819,6 +3993,7 @@ var stdlib = map[string][]string{
"DialUDP",
"DialUnix",
"Dialer",
"ErrClosed",
"ErrWriteToConnected",
"Error",
"FileConn",
@@ -3938,6 +4113,7 @@ var stdlib = map[string][]string{
"ErrUseLastResponse",
"ErrWriteAfterFlush",
"Error",
"FS",
"File",
"FileServer",
"FileSystem",
@@ -4234,7 +4410,10 @@ var stdlib = map[string][]string{
"Chtimes",
"Clearenv",
"Create",
"CreateTemp",
"DevNull",
"DirEntry",
"DirFS",
"Environ",
"ErrClosed",
"ErrDeadlineExceeded",
@@ -4243,6 +4422,7 @@ var stdlib = map[string][]string{
"ErrNoDeadline",
"ErrNotExist",
"ErrPermission",
"ErrProcessDone",
"Executable",
"Exit",
"Expand",
@@ -4276,6 +4456,7 @@ var stdlib = map[string][]string{
"Lstat",
"Mkdir",
"MkdirAll",
"MkdirTemp",
"ModeAppend",
"ModeCharDevice",
"ModeDevice",
@@ -4310,6 +4491,8 @@ var stdlib = map[string][]string{
"ProcAttr",
"Process",
"ProcessState",
"ReadDir",
"ReadFile",
"Readlink",
"Remove",
"RemoveAll",
@@ -4333,6 +4516,7 @@ var stdlib = map[string][]string{
"UserCacheDir",
"UserConfigDir",
"UserHomeDir",
"WriteFile",
},
"os/exec": []string{
"Cmd",
@@ -4347,6 +4531,7 @@ var stdlib = map[string][]string{
"Ignore",
"Ignored",
"Notify",
"NotifyContext",
"Reset",
"Stop",
},
@@ -4397,6 +4582,7 @@ var stdlib = map[string][]string{
"ToSlash",
"VolumeName",
"Walk",
"WalkDir",
"WalkFunc",
},
"plugin": []string{
@@ -4629,6 +4815,19 @@ var stdlib = map[string][]string{
"Stack",
"WriteHeapDump",
},
"runtime/metrics": []string{
"All",
"Description",
"Float64Histogram",
"KindBad",
"KindFloat64",
"KindFloat64Histogram",
"KindUint64",
"Read",
"Sample",
"Value",
"ValueKind",
},
"runtime/pprof": []string{
"Do",
"ForLabels",
@@ -5012,6 +5211,8 @@ var stdlib = map[string][]string{
"AddrinfoW",
"Adjtime",
"Adjtimex",
"AllThreadsSyscall",
"AllThreadsSyscall6",
"AttachLsf",
"B0",
"B1000000",
@@ -10010,13 +10211,20 @@ var stdlib = map[string][]string{
"TB",
"Verbose",
},
"testing/fstest": []string{
"MapFS",
"MapFile",
"TestFS",
},
"testing/iotest": []string{
"DataErrReader",
"ErrReader",
"ErrTimeout",
"HalfReader",
"NewReadLogger",
"NewWriteLogger",
"OneByteReader",
"TestReader",
"TimeoutReader",
"TruncateWriter",
},
@@ -10076,6 +10284,7 @@ var stdlib = map[string][]string{
"JSEscaper",
"Must",
"New",
"ParseFS",
"ParseFiles",
"ParseGlob",
"Template",
@@ -10087,12 +10296,14 @@ var stdlib = map[string][]string{
"BranchNode",
"ChainNode",
"CommandNode",
"CommentNode",
"DotNode",
"FieldNode",
"IdentifierNode",
"IfNode",
"IsEmptyTree",
"ListNode",
"Mode",
"New",
"NewIdentifier",
"NilNode",
@@ -10101,6 +10312,7 @@ var stdlib = map[string][]string{
"NodeBool",
"NodeChain",
"NodeCommand",
"NodeComment",
"NodeDot",
"NodeField",
"NodeIdentifier",
@@ -10118,6 +10330,7 @@ var stdlib = map[string][]string{
"NodeWith",
"NumberNode",
"Parse",
"ParseComments",
"PipeNode",
"Pos",
"RangeNode",
@@ -10230,6 +10443,7 @@ var stdlib = map[string][]string{
"Chakma",
"Cham",
"Cherokee",
"Chorasmian",
"Co",
"Common",
"Coptic",
@@ -10243,6 +10457,7 @@ var stdlib = map[string][]string{
"Devanagari",
"Diacritic",
"Digit",
"Dives_Akuru",
"Dogra",
"Duployan",
"Egyptian_Hieroglyphs",
@@ -10300,6 +10515,7 @@ var stdlib = map[string][]string{
"Katakana",
"Kayah_Li",
"Kharoshthi",
"Khitan_Small_Script",
"Khmer",
"Khojki",
"Khudawadi",
@@ -10472,6 +10688,7 @@ var stdlib = map[string][]string{
"Wancho",
"Warang_Citi",
"White_Space",
"Yezidi",
"Yi",
"Z",
"Zanabazar_Square",

View File

@@ -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 packagesinternal exposes internal-only fields from go/packages.
package packagesinternal
import (
"golang.org/x/tools/internal/gocommand"
)
var GetForTest = func(p interface{}) string { return "" }
var GetDepsErrors = func(p interface{}) []*PackageError { return nil }
type PackageError struct {
ImportStack []string // shortest path from package named on command line to this one
Pos string // position of error (if present, file:line:col)
Err string // the error itself
}
var GetGoCmdRunner = func(config interface{}) *gocommand.Runner { return nil }
var SetGoCmdRunner = func(config interface{}, runner *gocommand.Runner) {}
var TypecheckCgo int
var SetModFlag = func(config interface{}, value string) {}
var SetModFile = func(config interface{}, value string) {}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,153 @@
// Code generated by "stringer -type=ErrorCode"; DO NOT EDIT.
package typesinternal
import "strconv"
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[Test-1]
_ = x[BlankPkgName-2]
_ = x[MismatchedPkgName-3]
_ = x[InvalidPkgUse-4]
_ = x[BadImportPath-5]
_ = x[BrokenImport-6]
_ = x[ImportCRenamed-7]
_ = x[UnusedImport-8]
_ = x[InvalidInitCycle-9]
_ = x[DuplicateDecl-10]
_ = x[InvalidDeclCycle-11]
_ = x[InvalidTypeCycle-12]
_ = x[InvalidConstInit-13]
_ = x[InvalidConstVal-14]
_ = x[InvalidConstType-15]
_ = x[UntypedNil-16]
_ = x[WrongAssignCount-17]
_ = x[UnassignableOperand-18]
_ = x[NoNewVar-19]
_ = x[MultiValAssignOp-20]
_ = x[InvalidIfaceAssign-21]
_ = x[InvalidChanAssign-22]
_ = x[IncompatibleAssign-23]
_ = x[UnaddressableFieldAssign-24]
_ = x[NotAType-25]
_ = x[InvalidArrayLen-26]
_ = x[BlankIfaceMethod-27]
_ = x[IncomparableMapKey-28]
_ = x[InvalidIfaceEmbed-29]
_ = x[InvalidPtrEmbed-30]
_ = x[BadRecv-31]
_ = x[InvalidRecv-32]
_ = x[DuplicateFieldAndMethod-33]
_ = x[DuplicateMethod-34]
_ = x[InvalidBlank-35]
_ = x[InvalidIota-36]
_ = x[MissingInitBody-37]
_ = x[InvalidInitSig-38]
_ = x[InvalidInitDecl-39]
_ = x[InvalidMainDecl-40]
_ = x[TooManyValues-41]
_ = x[NotAnExpr-42]
_ = x[TruncatedFloat-43]
_ = x[NumericOverflow-44]
_ = x[UndefinedOp-45]
_ = x[MismatchedTypes-46]
_ = x[DivByZero-47]
_ = x[NonNumericIncDec-48]
_ = x[UnaddressableOperand-49]
_ = x[InvalidIndirection-50]
_ = x[NonIndexableOperand-51]
_ = x[InvalidIndex-52]
_ = x[SwappedSliceIndices-53]
_ = x[NonSliceableOperand-54]
_ = x[InvalidSliceExpr-55]
_ = x[InvalidShiftCount-56]
_ = x[InvalidShiftOperand-57]
_ = x[InvalidReceive-58]
_ = x[InvalidSend-59]
_ = x[DuplicateLitKey-60]
_ = x[MissingLitKey-61]
_ = x[InvalidLitIndex-62]
_ = x[OversizeArrayLit-63]
_ = x[MixedStructLit-64]
_ = x[InvalidStructLit-65]
_ = x[MissingLitField-66]
_ = x[DuplicateLitField-67]
_ = x[UnexportedLitField-68]
_ = x[InvalidLitField-69]
_ = x[UntypedLit-70]
_ = x[InvalidLit-71]
_ = x[AmbiguousSelector-72]
_ = x[UndeclaredImportedName-73]
_ = x[UnexportedName-74]
_ = x[UndeclaredName-75]
_ = x[MissingFieldOrMethod-76]
_ = x[BadDotDotDotSyntax-77]
_ = x[NonVariadicDotDotDot-78]
_ = x[MisplacedDotDotDot-79]
_ = x[InvalidDotDotDotOperand-80]
_ = x[InvalidDotDotDot-81]
_ = x[UncalledBuiltin-82]
_ = x[InvalidAppend-83]
_ = x[InvalidCap-84]
_ = x[InvalidClose-85]
_ = x[InvalidCopy-86]
_ = x[InvalidComplex-87]
_ = x[InvalidDelete-88]
_ = x[InvalidImag-89]
_ = x[InvalidLen-90]
_ = x[SwappedMakeArgs-91]
_ = x[InvalidMake-92]
_ = x[InvalidReal-93]
_ = x[InvalidAssert-94]
_ = x[ImpossibleAssert-95]
_ = x[InvalidConversion-96]
_ = x[InvalidUntypedConversion-97]
_ = x[BadOffsetofSyntax-98]
_ = x[InvalidOffsetof-99]
_ = x[UnusedExpr-100]
_ = x[UnusedVar-101]
_ = x[MissingReturn-102]
_ = x[WrongResultCount-103]
_ = x[OutOfScopeResult-104]
_ = x[InvalidCond-105]
_ = x[InvalidPostDecl-106]
_ = x[InvalidChanRange-107]
_ = x[InvalidIterVar-108]
_ = x[InvalidRangeExpr-109]
_ = x[MisplacedBreak-110]
_ = x[MisplacedContinue-111]
_ = x[MisplacedFallthrough-112]
_ = x[DuplicateCase-113]
_ = x[DuplicateDefault-114]
_ = x[BadTypeKeyword-115]
_ = x[InvalidTypeSwitch-116]
_ = x[InvalidExprSwitch-117]
_ = x[InvalidSelectCase-118]
_ = x[UndeclaredLabel-119]
_ = x[DuplicateLabel-120]
_ = x[MisplacedLabel-121]
_ = x[UnusedLabel-122]
_ = x[JumpOverDecl-123]
_ = x[JumpIntoBlock-124]
_ = x[InvalidMethodExpr-125]
_ = x[WrongArgCount-126]
_ = x[InvalidCall-127]
_ = x[UnusedResults-128]
_ = x[InvalidDefer-129]
_ = x[InvalidGo-130]
}
const _ErrorCode_name = "TestBlankPkgNameMismatchedPkgNameInvalidPkgUseBadImportPathBrokenImportImportCRenamedUnusedImportInvalidInitCycleDuplicateDeclInvalidDeclCycleInvalidTypeCycleInvalidConstInitInvalidConstValInvalidConstTypeUntypedNilWrongAssignCountUnassignableOperandNoNewVarMultiValAssignOpInvalidIfaceAssignInvalidChanAssignIncompatibleAssignUnaddressableFieldAssignNotATypeInvalidArrayLenBlankIfaceMethodIncomparableMapKeyInvalidIfaceEmbedInvalidPtrEmbedBadRecvInvalidRecvDuplicateFieldAndMethodDuplicateMethodInvalidBlankInvalidIotaMissingInitBodyInvalidInitSigInvalidInitDeclInvalidMainDeclTooManyValuesNotAnExprTruncatedFloatNumericOverflowUndefinedOpMismatchedTypesDivByZeroNonNumericIncDecUnaddressableOperandInvalidIndirectionNonIndexableOperandInvalidIndexSwappedSliceIndicesNonSliceableOperandInvalidSliceExprInvalidShiftCountInvalidShiftOperandInvalidReceiveInvalidSendDuplicateLitKeyMissingLitKeyInvalidLitIndexOversizeArrayLitMixedStructLitInvalidStructLitMissingLitFieldDuplicateLitFieldUnexportedLitFieldInvalidLitFieldUntypedLitInvalidLitAmbiguousSelectorUndeclaredImportedNameUnexportedNameUndeclaredNameMissingFieldOrMethodBadDotDotDotSyntaxNonVariadicDotDotDotMisplacedDotDotDotInvalidDotDotDotOperandInvalidDotDotDotUncalledBuiltinInvalidAppendInvalidCapInvalidCloseInvalidCopyInvalidComplexInvalidDeleteInvalidImagInvalidLenSwappedMakeArgsInvalidMakeInvalidRealInvalidAssertImpossibleAssertInvalidConversionInvalidUntypedConversionBadOffsetofSyntaxInvalidOffsetofUnusedExprUnusedVarMissingReturnWrongResultCountOutOfScopeResultInvalidCondInvalidPostDeclInvalidChanRangeInvalidIterVarInvalidRangeExprMisplacedBreakMisplacedContinueMisplacedFallthroughDuplicateCaseDuplicateDefaultBadTypeKeywordInvalidTypeSwitchInvalidExprSwitchInvalidSelectCaseUndeclaredLabelDuplicateLabelMisplacedLabelUnusedLabelJumpOverDeclJumpIntoBlockInvalidMethodExprWrongArgCountInvalidCallUnusedResultsInvalidDeferInvalidGo"
var _ErrorCode_index = [...]uint16{0, 4, 16, 33, 46, 59, 71, 85, 97, 113, 126, 142, 158, 174, 189, 205, 215, 231, 250, 258, 274, 292, 309, 327, 351, 359, 374, 390, 408, 425, 440, 447, 458, 481, 496, 508, 519, 534, 548, 563, 578, 591, 600, 614, 629, 640, 655, 664, 680, 700, 718, 737, 749, 768, 787, 803, 820, 839, 853, 864, 879, 892, 907, 923, 937, 953, 968, 985, 1003, 1018, 1028, 1038, 1055, 1077, 1091, 1105, 1125, 1143, 1163, 1181, 1204, 1220, 1235, 1248, 1258, 1270, 1281, 1295, 1308, 1319, 1329, 1344, 1355, 1366, 1379, 1395, 1412, 1436, 1453, 1468, 1478, 1487, 1500, 1516, 1532, 1543, 1558, 1574, 1588, 1604, 1618, 1635, 1655, 1668, 1684, 1698, 1715, 1732, 1749, 1764, 1778, 1792, 1803, 1815, 1828, 1845, 1858, 1869, 1882, 1894, 1903}
func (i ErrorCode) String() string {
i -= 1
if i < 0 || i >= ErrorCode(len(_ErrorCode_index)-1) {
return "ErrorCode(" + strconv.FormatInt(int64(i+1), 10) + ")"
}
return _ErrorCode_name[_ErrorCode_index[i]:_ErrorCode_index[i+1]]
}

View File

@@ -0,0 +1,45 @@
// 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 provides access to internal go/types APIs that are not
// yet exported.
package typesinternal
import (
"go/token"
"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
}
func ReadGo116ErrorData(terr types.Error) (ErrorCode, token.Pos, token.Pos, bool) {
var data [3]int
// By coincidence all of these fields are ints, which simplifies things.
v := reflect.ValueOf(terr)
for i, name := range []string{"go116code", "go116start", "go116end"} {
f := v.FieldByName(name)
if !f.IsValid() {
return 0, 0, 0, false
}
data[i] = int(f.Int())
}
return ErrorCode(data[0]), token.Pos(data[1]), token.Pos(data[2]), true
}