# Warning
**this repository is not maintained. Questions or suggestions can be posted [here](https://github.com/jteeuwen/discussions/issues).**
## bindata
This package converts any file into managable Go source code. Useful for
embedding binary data into a go program. The file data is optionally gzip
compressed before being converted to a raw byte slice.
It comes with a command line tool in the `go-bindata` sub directory.
This tool offers a set of command line options, used to customize the
output being generated.
### Installation
To install the library and command line program, use the following:
go get -u github.com/jteeuwen/go-bindata/...
### Usage
Conversion is done on one or more sets of files. They are all embedded in a new
Go source file, along with a table of contents and an `Asset` function,
which allows quick access to the asset, based on its name.
The simplest invocation generates a `bindata.go` file in the current
working directory. It includes all assets from the `data` directory.
$ go-bindata data/
To include all input sub-directories recursively, use the elipsis postfix
as defined for Go import paths. Otherwise it will only consider assets in the
input directory itself.
$ go-bindata data/...
To specify the name of the output file being generated, we use the following:
$ go-bindata -o myfile.go data/
Multiple input directories can be specified if necessary.
$ go-bindata dir1/... /path/to/dir2/... dir3
The following paragraphs detail some of the command line options which can be
supplied to `go-bindata`. Refer to the `testdata/out` directory for various
output examples from the assets in `testdata/in`. Each example uses different
command line options.
To ignore files, pass in regexes using -ignore, for example:
$ go-bindata -ignore=\\.gitignore data/...
### Accessing an asset
To access asset data, we use the `Asset(string) ([]byte, error)` function which
is included in the generated output.
data, err := Asset("pub/style/foo.css")
if err != nil {
// Asset was not found.
}
// use asset data
### Debug vs Release builds
When invoking the program with the `-debug` flag, the generated code does
not actually include the asset data. Instead, it generates function stubs
which load the data from the original file on disk. The asset API remains
identical between debug and release builds, so your code will not have to
change.
This is useful during development when you expect the assets to change often.
The host application using these assets uses the same API in both cases and
will not have to care where the actual data comes from.
An example is a Go webserver with some embedded, static web content like
HTML, JS and CSS files. While developing it, you do not want to rebuild the
whole server and restart it every time you make a change to a bit of
javascript. You just want to build and launch the server once. Then just press
refresh in the browser to see those changes. Embedding the assets with the
`debug` flag allows you to do just that. When you are finished developing and
ready for deployment, just re-invoke `go-bindata` without the `-debug` flag.
It will now embed the latest version of the assets.
### Lower memory footprint
Using the `-nomemcopy` flag, will alter the way the output file is generated.
It will employ a hack that allows us to read the file data directly from
the compiled program's `.rodata` section. This ensures that when we call
call our generated function, we omit unnecessary memcopies.
The downside of this, is that it requires dependencies on the `reflect` and
`unsafe` packages. These may be restricted on platforms like AppEngine and
thus prevent you from using this mode.
Another disadvantage is that the byte slice we create, is strictly read-only.
For most use-cases this is not a problem, but if you ever try to alter the
returned byte slice, a runtime panic is thrown. Use this mode only on target
platforms where memory constraints are an issue.
The default behaviour is to use the old code generation method. This
prevents the two previously mentioned issues, but will employ at least one
extra memcopy and thus increase memory requirements.
For instance, consider the following two examples:
This would be the default mode, using an extra memcopy but gives a safe
implementation without dependencies on `reflect` and `unsafe`:
```go
func myfile() []byte {
return []byte{0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a}
}
```
Here is the same functionality, but uses the `.rodata` hack.
The byte slice returned from this example can not be written to without
generating a runtime error.
```go
var _myfile = "\x89\x50\x4e\x47\x0d\x0a\x1a"
func myfile() []byte {
var empty [0]byte
sx := (*reflect.StringHeader)(unsafe.Pointer(&_myfile))
b := empty[:]
bx := (*reflect.SliceHeader)(unsafe.Pointer(&b))
bx.Data = sx.Data
bx.Len = len(_myfile)
bx.Cap = bx.Len
return b
}
```
### Optional compression
When the `-nocompress` flag is given, the supplied resource is *not* GZIP
compressed before being turned into Go code. The data should still be accessed
through a function call, so nothing changes in the usage of the generated file.
This feature is useful if you do not care for compression, or the supplied
resource is already compressed. Doing it again would not add any value and may
even increase the size of the data.
The default behaviour of the program is to use compression.
### Path prefix stripping
The keys used in the `_bindata` map, are the same as the input file name
passed to `go-bindata`. This includes the path. In most cases, this is not
desireable, as it puts potentially sensitive information in your code base.
For this purpose, the tool supplies another command line flag `-prefix`.
This accepts a portion of a path name, which should be stripped off from
the map keys and function names.
For example, running without the `-prefix` flag, we get:
$ go-bindata /path/to/templates/
_bindata["/path/to/templates/foo.html"] = path_to_templates_foo_html
Running with the `-prefix` flag, we get:
$ go-bindata -prefix "/path/to/" /path/to/templates/
_bindata["templates/foo.html"] = templates_foo_html
### Build tags
With the optional `-tags` flag, you can specify any go build tags that
must be fulfilled for the output file to be included in a build. This
is useful when including binary data in multiple formats, where the desired
format is specified at build time with the appropriate tags.
The tags are appended to a `// +build` line in the beginning of the output file
and must follow the build tags syntax specified by the go tool.
### Related projects
[go-bindata-assetfs](https://github.com/elazarl/go-bindata-assetfs#readme) -
implements `http.FileSystem` interface. Allows you to serve assets with `net/http`.
没有合适的资源?快使用搜索试试~ 我知道了~
ngrok 源码包,个人搭建ngrok内网穿透工具
5星 · 超过95%的资源 需积分: 5 14 下载量 48 浏览量
2022-04-27
16:25:20
上传
评论 1
收藏 17.57MB GZ 举报
温馨提示
共963个文件
go:261个
sample:117个
head:52个
ngrok 源码包,个人搭建ngrok内网穿透工具,已经搭建并投入使用
资源详情
资源评论
资源推荐
收起资源包目录
ngrok 源码包,个人搭建ngrok内网穿透工具 (963个子文件)
0322578be33f08b9a55cc845c8587be2c4e5c9 827B
054156b25a8d3013f8a97a4a9b0ad530d2cbae 573B
0571bbfc0f7d6639dbed2e6e055c0cbdeace71 279B
05937f8c72565fec741d8a1704c1f24a4fc67d 575B
06cb115d2027de010add37cb862558219935fa 665B
072ce59707ec8b822fa918a541278fe0aaea00 876B
095f13c88590ace5d1d1c83d60dbfc5fcbe11f 220B
0a919e209abc864671d83d6e7b5cfc6a2578b2 428B
0ab0c046f89e738baa313582d1bca3f0351d89 2KB
0b698ca1e8a5b4c118c3bfc335da208033caa2 334B
0bbab50f4addad25bda58dc81c290a7524d76c 341B
0bdedcec81610e93fd6e67b3e81e23d0df22d1 164B
0be690d6f2ab3e4fe00a82c21f28eb66c85068 124B
0d1fb6a7bbfdb5f1af9c717888e59a0d146e26 373B
0d1fb6a7bbfdb5f1af9c717888e59a0d146e26 373B
0d9fc77a5dfb895ad0b2731b6838cab5ca901a 165B
0da370e4d7a1ec990f491f6e2068b9db76725f 171B
0e615427b66c8cf04257325cb7e94cc21a1727 397B
0e7de772656c6127fa8e55c6258ed1b7eabcee 212B
0fe9dcc49eddfd953204cd81969b11653282d5 425B
10c8563d8cac71f9d2ffa423baa8ca0a201a1f 125B
111cb4b5c1a3aec64778b41ed639948dac07b2 176B
155c051e9efa48fcc164f708442fd7a7882b1c 248B
156848332c4a490f1a6865db3ff971c7d5249e 112B
199924d411238f3f8aa4fbca923cdf7421a7ec 123B
1a77733bc473b51acd20f73665fc556481d64d 411B
1c29f7cf8ef6f0e9ae4a27134591a42877bc11 431B
1c5e990f7d209eb8361804a23bea785752e859 363B
1f6b49be32b7b0a601b3dd263e356c8a8b85e6 478B
1ff4bface940f68f4785f50447c53c3a4c7d03 165B
207ad94817fccea336ed13c24411bec93b3812 1KB
207cd8a24d632848b9e2bdbddc06a08459576a 35B
20ff3b2f374974fe86ab2445542fe4d43a6c43 442B
224a99df24f933b89e919c47761928b71eb21e 514B
22e3f742ee6bc17e4be5b84bdec2025a8e05b7 345B
231a238262436143edb7be1db787c2a37ec287 3KB
2393053727f33924022c483111d3b0196c59e4 424B
24302b36f07bb05a9032958cdc41756d9674ca 1KB
25434f4a38f5604090e4d1e0c4b05e22fa18c5 13KB
28b15e01cb2f1d264848b93d461e6186438bd7 4KB
28e57c3c30bd44ab31b5743cfc5178a6bc3a19 601B
2bcea08b1e082175a8173a96e1c157b08f2402 288B
2cd66093e7b7f7c5b1d77e46c94c46f33c941c 163B
2cdbe2dff6a7f7f9bcdbd80fdf30fb775d8e13 3KB
2d8a4bab92ae5f97a305ca195aa23d8df1d41a 295B
2d951bb4db1f2ec0ab0c38877cddf18ceb15ea 2KB
2e890ccbe640ff32797599418fe921f7c0a69c 4KB
2f7ace995d9f0baec366e7b0c0ec286894ccf6 173B
3121d4b110d56695bc07e1207e355bb6bc1948 99B
34a5c68e3a58cbfd89c63a360f2760c0a199ce 3KB
350a6ddd3016550e5bc05ff55bee1ee67642bb 411B
35450ff8b987ec4373f65c40767f096b35f2d2 303B
36ccb65db397b9fc59855debc15d8c4603fec2 3KB
3a39aa6843b77797e2ec29c26547fac8cf0c36 233B
3abbece15d7d5a39165fd2f2a27af33cdbbd91 345B
3b64083c0432abc025e278bf774a12f05b1c08 260B
3c3898c36b066c3fc7c145c8ee76c6389762aa 645B
3c713e312ab50dc03a73af74df44dd6d9f146a 243B
3cc2d3e92b402c06b570ac781231c02e9e0e2e 187B
3f1601457453f8172128ec45ead08017a3d67f 22B
3fb74b87349698c014310a3c7281d6bbb87c25 132B
40f1ef808d9c013fb352bf8ae67a242d9a5208 657B
4280b2ded330ff0768bdafae30e742d261b9d0 55B
45c746338654909da47580adfd16c5a528a0a1 150B
46e6b86faab5f7e4d135cc63b749d74bf0d4a6 611B
483c3a262ff20b466f186940bf3235379e9208 341B
48b69f563d1b26feb8b2a110e9d5959443cb9a 2KB
49085906bfb0e063c1d25fbc6defcacbe3fb53 1KB
49e1d4b66167acc238efe4b5d79db85a770ba6 180B
49f083b7f79f255bafa1f1d27d4525efa36dc5 261B
4aa0a893836c01a57db56ee5b9bdb25b00bf40 156B
4c2add4f780a12d2771cd89741a7cc59ddfeea 273B
4ca83806655aff338d1eba827473906896080f 215B
4d65304107a62f538286b18318d70fb299e549 240B
4d973327c2823966129921c16936b8a285e185 423B
4e857f519b0b877993296d4618046ec341c97b 4KB
4edc4bd518bc1cce4c0a88c5454fa9d663f056 370B
50367ab8a1a69c02df15d9783d60d2bf4074c9 198B
5161668d7cbef8fd6e87df287df0f706b2ef26 406B
516b81df2eab059457c8bbd68dc2dc37bfce24 375B
52771b1b369e66773802b7851dc74939c272e4 264B
5538bd899184b2e392b0789bfc97fd543db858 1KB
55b0ab8708602d411341e55fffd7e0700f86bd 161B
5729fc1bcbc6fdda2a72b63cf9e381a83915fb 157B
58309fb1dce068c83671adfe43fdfcc8fa1d23 320B
599f61564f35d410892569202c79aed80ee28e 13KB
59b874410abc6f0e499a52804ca6d380753565 363B
5ab588399b64aad4ef75a44cd017aab2e4fd71 32KB
5b1312f882b0d661e849d148da10bd773c901b 125B
5c0722f2c220e3baca7708b985cd488096b9b2 119B
60b7195d4e968b469d4383825d06f35df5b737 112B
6142a5e3ec4c6cd2f5f3fb8706def45c758e88 1003B
61567f729567e17ec64c02a3fc5348a5cce820 233B
616543e7b228cef1b9ff4a165e39fc2ecfcf36 2KB
61ad77399423db2eccf9a028c575aff7ed67e1 478B
626ae9c91c4f2a10f34cad8ce83ea42c93bb75 244B
6437b2169c2c916466c4a33f315a51a5d1b0ff 187B
64d7e339a756c75ab2b7c1131b423105792d68 248B
64e0c8a6c0b388e90238f2d5c1568391743baa 435B
666fd8a517e53597c5a98531fb5bf8d5750272 277B
共 963 条
- 1
- 2
- 3
- 4
- 5
- 6
- 10
杨豆芽
- 粉丝: 22
- 资源: 15
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 论文(最终)_20240430235101.pdf
- 基于python编写的Keras深度学习框架开发,利用卷积神经网络CNN,快速识别图片并进行分类
- 最全空间计量实证方法(空间杜宾模型和检验以及结果解释文档).txt
- 5uonly.apk
- 蓝桥杯Python组的历年真题
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 前端开发技术实验报告:内含4四实验&实验报告
- Highlight Plus v20.0.1
- 林周瑜-论文.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论5