Go每日一库之142:esc(嵌入静态文件)

发布时间 2023-09-29 21:54:14作者: 阿瑞娜

go-bindata 类似,esc 同样提供了将静态文件转换为go源码并暴露了类似于http.FileSystem的API来读取数据的功能。

安装

go get -u github.com/mjibson/esc

使用

https://github.com/mjibson/esc#example

对比:

go-bindata、go.rice 和 esc 简单对比:https://studygolang.com/articles/5068
esc 没有 go-bindata 那样丰富的API,但会将嵌入的字节数据压缩,大大缩小了代码以及编译后的二进制程序体积。