gpt4 book ai didi

testing - 为特定的操作系统或架构去测试文件

转载 作者:IT王子 更新时间:2023-10-29 01:36:41 26 4
gpt4 key购买 nike

在 Go 中,文件名具有语义。例如:

*_windows.go // Only include in compilations for Windows
*_unix.go // Only include in compilations for Unix
*_386.go // Only include in compilations for 386 systems
*_test.go // Only include when run with `go test`

但是,我似乎无法让以下工作正常进行:

*_windows_test.go // Only include when running `go test` on windows
*_test_windows.go // Another attempt

这甚至可以用 Go 实现吗?如果是,怎么办?

最佳答案

只需使用 build constraint在测试文件上。

// +build windows

A build constraint is evaluated as the OR of space-separated options; each option evaluates as the AND of its comma-separated terms; and each term is an alphanumeric word or, preceded by !, its negation. That is, the build constraint:

关于testing - 为特定的操作系统或架构去测试文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28387378/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com