// Copyright 2021 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 typeparamsimport ()func ( ast.Expr, token.Pos, []ast.Expr, token.Pos) ast.Expr {switchlen() {case0:panic("internal error: PackIndexExpr with empty expr slice")case1:return &ast.IndexExpr{X: ,Lbrack: ,Index: [0],Rbrack: , }default:return &ast.IndexListExpr{X: ,Lbrack: ,Indices: ,Rbrack: , } }}// IndexExpr wraps an ast.IndexExpr or ast.IndexListExpr.//// Orig holds the original ast.Expr from which this IndexExpr was derived.//// Note: IndexExpr (intentionally) does not wrap ast.Expr, as that leads to// accidental misuse such as encountered in golang/go#63933.//// TODO(rfindley): remove this helper, in favor of just having a helper// function that returns indices.typeIndexExprstruct { Orig ast.Expr// the wrapped expr, which may be distinct from the IndexListExpr below. X ast.Expr// expression Lbrack token.Pos// position of "[" Indices []ast.Expr// index expressions Rbrack token.Pos// position of "]"}func ( *IndexExpr) () token.Pos {return .Orig.Pos()}func ( ast.Node) *IndexExpr {switch e := .(type) {case *ast.IndexExpr:return &IndexExpr{Orig: ,X: .X,Lbrack: .Lbrack,Indices: []ast.Expr{.Index},Rbrack: .Rbrack, }case *ast.IndexListExpr:return &IndexExpr{Orig: ,X: .X,Lbrack: .Lbrack,Indices: .Indices,Rbrack: .Rbrack, } }returnnil}
The pages are generated with Goldsv0.7.0-preview. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.