我们可以在Golang可测试示例的输出注释中使用正则表达式吗?

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

Can we use regular expression in Golang testable example Output comment?

问题

我有一个示例,它执行一些计时操作,并在最后输出结果。由于结果永远不会相同,是否有办法在输出注释中使用正则表达式或类似的东西?

类似下面的方式:

...
// 输出:
// 时间:\d*(秒)
...

谢谢

英文:

I have an example that performs some timing and output the result at the end. Since the result will never be the same, is there a way to use regular expression or something similar in the Output comment?

Something like below:

...
// Output:
// Time: \d*\(s\)
...

Thanks

答案1

得分: 2

我们可以在Golang可测试示例的输出注释中使用正则表达式吗?

不可以。

这必须完全匹配。

英文:

> Can we use regular expression in Golang testable example Output comment?

No.

This must match literally.

huangapple
  • 本文由 发表于 2021年8月20日 23:25:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/68864602.html
匿名

发表评论

匿名网友

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

确定