)]}'
{
  "commit": "a1b7ff21027be138c00498d328fcd2af698e259a",
  "tree": "5e60849a0bee4bbb1e25b59ccaec9905e1b0dc6c",
  "parents": [
    "fea258518fde664e76a76272b54a8e228416d4f9"
  ],
  "author": {
    "name": "H5-O5",
    "email": "166461697+H5-O5@users.noreply.github.com",
    "time": "Thu Jul 16 12:04:42 2026 -0700"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Thu Jul 16 19:04:42 2026 +0000"
  },
  "message": "feat(go): add directives to set Go/C compiler and linker flags on generated rules (#2372)\n\nImplements #2371.\n\nAdds a family of Go directives that set string-list compiler/linker\nattributes on generated rules. The main motivation is applying flags to\nexternal dependencies generated by `go_deps`, which have no hand-written\nbuild files to edit — the directives flow through the existing\n`directives` channel of `go_deps.gazelle_default_attributes` /\n`gazelle_override`.\n\n| Directive | Attribute | Applied to | Gate |\n|---|---|---|---|\n| `# gazelle:go_gc_goopts` | `gc_goopts` | `go_library` / `go_binary` /\n`go_test` with sources | — |\n| `# gazelle:go_gc_linkopts` | `gc_linkopts` | `go_binary`, `go_test` |\n— |\n| `# gazelle:go_copts` | `copts` | cgo targets (`go_library`) | `cgo \u003d\nTrue` |\n| `# gazelle:go_cppopts` | `cppopts` | cgo targets (`go_library`) | `cgo\n\u003d True` |\n| `# gazelle:go_cxxopts` | `cxxopts` | cgo targets (`go_library`) | `cgo\n\u003d True` |\n| `# gazelle:go_clinkopts` | `clinkopts` | cgo targets (`go_library`) |\n`cgo \u003d True` |\n\n**Notes on design (per discussion in the issue):**\n- The C flags (`copts`/`cppopts`/`cxxopts`/`clinkopts`) are **merged**\nwith the flags Gazelle derives from `#cgo` comments, not overwritten.\n- `clinkopts` is set on `go_library`, matching where the source-derived\n`clinkopts` already go. Gazelle never generates a cgo\n`go_binary`/`go_test` (cgo isn\u0027t allowed in `_test.go`, and a cgo `main`\nbecomes a cgo `go_library` embedded by a plain `go_binary`), so in\npractice all C flags land on `go_library`.\n- `gc_goopts`/`gc_linkopts` are set directly (not derived from source);\n`gc_goopts` needs sources to compile, `gc_linkopts` applies to the\nlinking rules.\n- Values may be separated by whitespace and/or commas (`-N -l` is\nequivalent to `-N,-l`); an empty value resets the directive.\n\n**Tests**\n- Unit tests for directive parsing, reset, and inheritance\n(`config_test.go`).\n- A generate golden (`testdata/compiler_flags`) exercising emission, the\ncgo gate, the library-vs-linking gate, and merging with `#cgo`-derived\nflags.\n- `go test ./language/go/` passes; new/changed files are `gofmt`-clean.\n\n**Docs**\n- `language/go/reference.md` documents all six directives.\n\n*Drafted with Claude Code.*\n\n---------\n\nCo-authored-by: Claude Opus 4.8 \u003cnoreply@anthropic.com\u003e\nCo-authored-by: Jay Conrod \u003cjay@engflow.com\u003e",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "eb07e295f4ca1f1fda3ce4e17906fd023d13caeb",
      "old_mode": 33188,
      "old_path": "language/go/config.go",
      "new_id": "dbb52829251d4bb87b0b7dff3528217e3cdf79dc",
      "new_mode": 33188,
      "new_path": "language/go/config.go"
    },
    {
      "type": "modify",
      "old_id": "fc2eafef2c57f245efd76a980fa7f34395be60cd",
      "old_mode": 33188,
      "old_path": "language/go/config_test.go",
      "new_id": "8125a64eee641fc7265a3c1cd71d56e3c68aa0dc",
      "new_mode": 33188,
      "new_path": "language/go/config_test.go"
    },
    {
      "type": "modify",
      "old_id": "c7a2001f77493e4b606cc876a059e3ef0105af09",
      "old_mode": 33188,
      "old_path": "language/go/generate.go",
      "new_id": "d1eea17f545179db0000bdbcaa89fdb74259003a",
      "new_mode": 33188,
      "new_path": "language/go/generate.go"
    },
    {
      "type": "modify",
      "old_id": "ad31add221b68b86dd0290d8e7028d663f548389",
      "old_mode": 33188,
      "old_path": "language/go/kinds.go",
      "new_id": "3b396ba1f74e9e46711cba3d8789cf5ad58754c3",
      "new_mode": 33188,
      "new_path": "language/go/kinds.go"
    },
    {
      "type": "modify",
      "old_id": "cc3e703903e6308bd3e8aa1b6070188ceb0a0c5f",
      "old_mode": 33188,
      "old_path": "language/go/reference.md",
      "new_id": "52696494d1b44ae77dc9afb5821ea30e23788ee8",
      "new_mode": 33188,
      "new_path": "language/go/reference.md"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "6df20f888675c6d6aec6c27086da1c2971397e4c",
      "new_mode": 33188,
      "new_path": "language/go/testdata/compiler_flags/BUILD.old"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "801a2f79f33525710330d733573b2d53eda083f5",
      "new_mode": 33188,
      "new_path": "language/go/testdata/compiler_flags/BUILD.want"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "d4df18e7dd6a85806f610a897fbe66822b6dfc29",
      "new_mode": 33188,
      "new_path": "language/go/testdata/compiler_flags/foo.go"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "17b542ba9656bb3174789158438d32d5d869e9d3",
      "new_mode": 33188,
      "new_path": "language/go/testdata/compiler_flags/foo_test.go"
    }
  ]
}
