You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Go测试文件默认缓存位置及各平台官方路径咨询

Go Test Cache Default Locations Across Platforms

Great question—you’re totally right that the official Go docs don’t spell out the test cache directories for every platform in a single, easy-to-find spot. But let’s break this down clearly, based on Go’s actual behavior and source code:

  • Linux: Your initial guess was spot-on! The test cache lives under $HOME/.cache/go-build. This is part of Go’s broader build cache, which stores test results, compiled packages, and other build artifacts.
  • macOS: It follows macOS’s standard cache conventions, sitting at $HOME/Library/Caches/go-build.
  • Windows: On Windows systems, the cache directory is %LocalAppData%\go-build (this typically resolves to a path like C:\Users\<YourUsername>\AppData\Local\go-build).

How to Verify the Exact Path on Your System

If you want a foolproof way to confirm the cache location for your specific environment (even if you’ve set a custom GOCACHE variable), run this command in your terminal:

go env GOCACHE

This will print the root directory of Go’s build cache, which includes all test result caches. Go manages the internal subdirectory structure automatically, so you don’t need to navigate into those folders directly—go test handles checking and invalidating the cache whenever source files, dependencies, or build flags change.

内容的提问来源于stack exchange,提问作者syscll

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.12 04:59:22