Golang-参数过多

huangapple go评论72阅读模式
英文:

Golang-too many arguments

问题

我尝试测试它,但出错了。

<https://github.com/awesome-cmd/dchat/blob/3cf074d33e6be93596ba8484eff4a5152dd1307b/client/spi_test.go#L10>

package server

import "testing"

func TestRun(t *testing.T) {
	Run([]string{"3333"})
}

vscode 返回:

{
	"resource": "GitHub/dchat/client/spi_test.go",
	"owner": "_generated_diagnostic_collection_name_#2",
	"severity": 8,
	"message": "参数过多",
	"source": "compiler",
	"startLineNumber": 10,
	"startColumn": 6,
	"endLineNumber": 10,
	"endColumn": 6
}

请帮助我。

英文:

I try to test it,but wrong.

<https://github.com/awesome-cmd/dchat/blob/3cf074d33e6be93596ba8484eff4a5152dd1307b/client/spi_test.go#L10>

package server

import &quot;testing&quot;

func TestRun(t *testing.T) {
	Run([]string{&quot;3333&quot;})
}

vscode return :

{
	&quot;resource&quot;: &quot;GitHub/dchat/client/spi_test.go&quot;,
	&quot;owner&quot;: &quot;_generated_diagnostic_collection_name_#2&quot;,
	&quot;severity&quot;: 8,
	&quot;message&quot;: &quot;too many arguments&quot;,
	&quot;source&quot;: &quot;compiler&quot;,
	&quot;startLineNumber&quot;: 10,
	&quot;startColumn&quot;: 6,
	&quot;endLineNumber&quot;: 10,
	&quot;endColumn&quot;: 6
}

Please help me.

答案1

得分: -1

你的Run()函数没有定义任何参数。
尝试使用func Run(list []string)

你在为你的项目编写测试方面做得很好。

英文:

Your Run() does not have any parameters defined.
Try func Run(list []string)

Good job on writing tests for your project.

huangapple
  • 本文由 发表于 2021年6月14日 08:32:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/67963632.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定