配置好vscode的go开发环境之后,在默认情况下在控制台t.Log(a)是不会打印内容的,如:
package fibnac
import (
"fmt"
"testing"
)
func TestFib(t *testing.T) {
a := 1
b := 1
t.Log(a)
fmt.Print("打印:",a)
for i := 0; i < 5; i++ {
t.Log(" ", b)
tmp := a
a = b
b = tmp + a
}
}
控制台output内容:
解决方法
file->preference->setting->workspace->extensions->go->Test Flags
编辑这里的json:
{
"C_Cpp.commentContinuationPatterns": [
"/**"
],
"editor.codeActionsOnSave": null,
"go.alternateTools": {
},
"go.liveErrors": {
"enabled": false,
"delay": 500
},
"go.testFlags": ["-v"]
}