How to embed file for later parsing execution use

前端 未结 3 924
轻奢々
轻奢々 2020-11-30 23:55

I am essentially trying to walk through a folder of html files. I want to embed them into the binary file and be able to parse them upon request for template execution purpo

3条回答
  •  天涯浪人
    2020-12-01 00:41

    Another tool to consider: Another recent good tool comes from esc: Embedding Static Assets in Go (GitHub repo)

    a program that:

    • can take some directories and recursively embed all files in them in a way that was compatible with http.FileSystem
    • can optionally be disabled for use with the local file system for local development
    • will not change the output file on subsequent runs
    • has reasonable-sized diffs when files changed
    • is vendoring-friendly

    Vendoring-friendly means that when I run godep or party, the static embed file will not change.
    This means it must not have any third-party imports (since their import path will be rewritten during goimports, and thus different than what the tool itself produces), or a specifiable location for the needed third-party imports.

    It generates nice, gzipped strings, one per file.
    There is a simple flag to enable local development mode, which is smart enough to not strip directory prefixes off of filenames (an option in esc that is sometimes needed).
    The output includes all needed code, and does not depend on any third-party libraries for compatibility with http.FileSystem.

提交回复
热议问题