<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>cache on tac lifelog</title>
    <link>https://tro3373.github.io/tags/cache/</link>
    <description>Recent content in cache on tac lifelog</description>
    <image>
      <title>tac lifelog</title>
      <url>https://tro3373.github.io/favicon.png</url>
      <link>https://tro3373.github.io/favicon.png</link>
    </image>
    <generator>Hugo -- gohugo.io</generator>
    <language>ja</language>
    <lastBuildDate>Wed, 07 Oct 2026 13:38:10 +0900</lastBuildDate><atom:link href="https://tro3373.github.io/tags/cache/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Go のキャッシュが追わない入力と巻き込む範囲</title>
      <link>https://tro3373.github.io/posts/2026/2026-10-07-go-build-test-cache-pitfalls/</link>
      <pubDate>Wed, 07 Oct 2026 13:38:10 +0900</pubDate>
      
      <guid>https://tro3373.github.io/posts/2026/2026-10-07-go-build-test-cache-pitfalls/</guid>
      <description>結論 go test の結果キャッシュは、テストバイナリ・cacheable なフラグ・テストが読んだ環境変数・モジュールの中で開いたファイルで照合する。モジュールの外のファイルは、書き換えても (cached) のまま緑になる 境界はパッケージのディレクトリではなくモジュールルート。外のフィクスチャは、モジュール内に張った symlink 越しに読めば追跡される -coverprofile / -coverpkg 付きの実行もキャッシュされ、カバレッジ率も前回の値が出る GOFLAGS=-count=1 は、そのフラグを持たない go build / vet / list / fmt / run では無視され、エラーにならない。Makefile で export すれば、全ターゲットの go test をキャッシュから外せる CGO_ENABLED を変えると、cgo のファイルを持つ net と、それを import するパッケージがすべて別のキーで作り直される ビルドキャッシュはユーザ単位で、全リポジトリが共有する。1 つのリポジトリの go clean -cache / -testcache が、同じマシンの全プロジェクトに効く 以下は Go 1.26.4 (linux/amd64) で実測した。実験では GOCACHE を一時ディレクトリに向け、手元のキャッシュには触れていない。
前提: テスト結果のキャッシュは何で照合するか go help test は次のとおり書いている。
The rule for a match in the cache is that the run involves the same test binary and the flags on the command line come entirely from a restricted set of &amp;lsquo;cacheable&amp;rsquo; test flags, defined as -benchtime, -coverprofile, -cpu, -failfast, -fullpath, -list, -outputdir, -parallel, -run, -short, -skip, -timeout and -v.</description>
    </item>
    
  </channel>
</rss>
