> For the complete documentation index, see [llms.txt](https://go-macaron.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://go-macaron.com/zh-cn/middlewares/bindata.md).

# 嵌入二进制数据

模块 bindata 用于为 [Macaron 实例](/zh-cn/core_concepts.md#macaron-shi-li) 提供支持内存的静态文件服务和模板文件系统。

* [GitHub](https://github.com/go-macaron/bindata)
* [API 文档](https://gowalker.org/github.com/go-macaron/bindata)

### 下载安装

```bash
go get github.com/go-macaron/bindata
```

## 使用示例

使用 [go-bindata](https://github.com/go-bindata/go-bindata) 将相应的静态文件和模板文件转换成单独的包。

导入相应的包并通过如下方法实现支持：

```go
import (
    "path/to/bindata/public"
    "path/to/bindata/templates"
    "github.com/go-macaron/bindata"
)

m.Use(macaron.Static("public",
    macaron.StaticOptions{
        FileSystem: bindata.Static(bindata.Options{
            Asset:      public.Asset,
            AssetDir:   public.AssetDir,
            AssetNames: public.AssetNames,
            Prefix:     "",
        }),
    },
))

m.Use(macaron.Renderer(macaron.RenderOptions{
    TemplateFileSystem: bindata.Templates(bindata.Options{
        Asset:      templates.Asset,
        AssetDir:   templates.AssetDir,
        AssetNames: templates.AssetNames,
        Prefix:     "",
    }),
}))
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://go-macaron.com/zh-cn/middlewares/bindata.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
