github.com/cockroachdb/tools@v0.0.0-20230222021103-a6d27438930d/internal/gcimporter/support_go118.go (about)

     1  // Copyright 2021 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 file.
     4  
     5  //go:build go1.18
     6  // +build go1.18
     7  
     8  package gcimporter
     9  
    10  import "go/types"
    11  
    12  const iexportVersion = iexportVersionGenerics
    13  
    14  // additionalPredeclared returns additional predeclared types in go.1.18.
    15  func additionalPredeclared() []types.Type {
    16  	return []types.Type{
    17  		// comparable
    18  		types.Universe.Lookup("comparable").Type(),
    19  
    20  		// any
    21  		types.Universe.Lookup("any").Type(),
    22  	}
    23  }
    24  
    25  // See cmd/compile/internal/types.SplitVargenSuffix.
    26  func splitVargenSuffix(name string) (base, suffix string) {
    27  	i := len(name)
    28  	for i > 0 && name[i-1] >= '0' && name[i-1] <= '9' {
    29  		i--
    30  	}
    31  	const dot = "ยท"
    32  	if i >= len(dot) && name[i-len(dot):i] == dot {
    33  		i -= len(dot)
    34  		return name[:i], name[i:]
    35  	}
    36  	return name, ""
    37  }