# cgo を利用するプロジェクトをビルドする方法

## cgo

cgo は Go のビルドツールチェーンに組み込まれた仕組みで、Go コードから C/C++ の関数やライブラリを呼び出すためのブリッジです。\
diarkis-cli では cgo がデフォルトでは無効化されているので、明示的に有効化する必要があります。

## ビルド方法

`build.yml` 内の env セクションに下記を追加することで cgo と gcc を使って C プログラムを呼び出す go のプログラムをビルドすることができます。

```yaml
CGO_ENABLED: 1
CC: gcc
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.diarkis.io/diarkis-tool/diarkis-cli/how-to-build-with-cgo.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
