golang中``Type`的含义是什么?

soa*_*bar 7 go

这段代码在builti.go中

// The append built-in function appends elements to the end of a slice. If
// it has sufficient capacity, the destination is resliced to accommodate the
// new elements. If it does not, a new underlying array will be allocated.
// Append returns the updated slice. It is therefore necessary to store the
// result of append, often in the variable holding the slice itself:
//  slice = append(slice, elem1, elem2)
//  slice = append(slice, anotherSlice...)
// As a special case, it is legal to append a string to a byte slice, like this:
//  slice = append([]byte("hello "), "world"...)
func append(slice []Type, elems ...Type) []Type
Run Code Online (Sandbox Code Playgroud)

最后一行让我感到非常困惑.我不知道这个意思builti.go.

这是其他代码.

package main

import "fmt"

func main() {
   s := []int{1,2,3,4,5}
   s1 := s[:2]
   s2 := s[2:]
   s3 := append(s1, s2...)
   fmt.Println(s1, s2, s3)
}
Run Code Online (Sandbox Code Playgroud)

}

结果是

[1 2] [3 4 5] [1 2 3 4 5]
Run Code Online (Sandbox Code Playgroud)

我想函数...Type是从elems中选择所有元素.

我找不到官方的解释

Cer*_*món 9

builtin.go中的代码用作文档.代码未编译.

...指出这个函数的最后一个参数是可变参数.Go语言规范记录了变量参数.

类型的部分为任何围棋类型替身.

  • 这是一篇关于切片的好文章,可能会很有帮助:https://github.com/golang/go/wiki/SliceTricks (2认同)