filepath.Join方法接受一个...string参数,但我有一个[]string我想传入的.当我尝试这样做时,我得到以下错误:
cannot use append(elems, spadePath) (type []string) as type string in argument to filepath.Join
Run Code Online (Sandbox Code Playgroud)
有没有办法在[]类型和...类型之间进行转换?
...通过在作为参数传入时附加到切片,找到了一种方法.
例如,我最初试图调用make以下调用产生错误:
filepath.Join(append(elems, basePath))
Run Code Online (Sandbox Code Playgroud)
但是我通过...在论证中加入来纠正它:
filepath.Join(append(elems, basePath)...)
Run Code Online (Sandbox Code Playgroud)