{"id":25195145,"url":"https://github.com/siongui/goef","last_synced_at":"2025-09-18T16:54:11.200Z","repository":{"id":57551125,"uuid":"88449936","full_name":"siongui/goef","owner":"siongui","description":"Embed file in your Go code","archived":false,"fork":false,"pushed_at":"2021-06-10T18:41:17.000Z","size":41,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-08T02:46:41.575Z","etag":null,"topics":["embed-code","embed-files","go","golang","virtual-file-system"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/siongui.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-16T23:53:52.000Z","updated_at":"2021-06-10T18:41:20.000Z","dependencies_parsed_at":"2022-09-26T18:41:20.937Z","dependency_job_id":null,"html_url":"https://github.com/siongui/goef","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/siongui/goef","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siongui%2Fgoef","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siongui%2Fgoef/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siongui%2Fgoef/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siongui%2Fgoef/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/siongui","download_url":"https://codeload.github.com/siongui/goef/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siongui%2Fgoef/sbom","scorecard":{"id":827470,"data":{"date":"2025-08-11","repo":{"name":"github.com/siongui/goef","commit":"d3b60554c5f3ab811217d3f219384a50bfe5e2ee"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/build.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/siongui/goef/build.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/siongui/goef/build.yml/master?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: UNLICENSE:0","Info: FSF or OSI recognized license: The Unlicense: UNLICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-23T16:54:04.253Z","repository_id":57551125,"created_at":"2025-08-23T16:54:04.253Z","updated_at":"2025-08-23T16:54:04.253Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275798595,"owners_count":25530280,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-18T02:00:09.552Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["embed-code","embed-files","go","golang","virtual-file-system"],"created_at":"2025-02-10T00:50:16.695Z","updated_at":"2025-09-18T16:54:11.139Z","avatar_url":"https://github.com/siongui.png","language":"Go","readme":"==========================\nEmbed Files in Go_ Package\n==========================\n\n.. image:: https://img.shields.io/badge/Language-Go-blue.svg\n   :target: https://golang.org/\n\n.. image:: https://godoc.org/github.com/siongui/goef?status.svg\n   :target: https://godoc.org/github.com/siongui/goef\n\n.. .. image:: https://api.travis-ci.org/siongui/goef.svg?branch=master\n   :target: https://travis-ci.org/siongui/goef\n\n.. image:: https://github.com/siongui/goef/workflows/Test%20Package/badge.svg\n    :target: https://github.com/siongui/goef/blob/master/.github/workflows/build.yml\n\n.. image:: https://goreportcard.com/badge/github.com/siongui/goef\n   :target: https://goreportcard.com/report/github.com/siongui/goef\n\n.. image:: https://img.shields.io/badge/license-Unlicense-blue.svg\n   :target: https://raw.githubusercontent.com/siongui/goef/master/UNLICENSE\n\n.. image:: https://img.shields.io/badge/Status-Beta-brightgreen.svg\n\n.. image:: https://img.shields.io/twitter/url/https/github.com/siongui/goef.svg?style=social\n   :target: https://twitter.com/intent/tweet?text=Wow:\u0026url=%5Bobject%20Object%5D\n\nEmbed Files in Go_ Package.\n\n.. contents:: Table of Contents\n\n\nFeatures\n++++++++\n\n- Embedded files are read-only.\n- Can be used in front-end code via GopherJS_, or local Go program.\n- Can be included in your Go package, or put in a separate package.\n- With limit of max single file size. (only for plain-text files)\n- Support embedding symbolic links (only GenerateGoPackage_ method)\n\n\nHow It Works\n++++++++++++\n\nThe files to be embedded in Go code will be encoded in base64_ format. The\n(name, content) of the files will be put in the (key, value) pairs of Go\nbuilt-in map_ structure, and *ReadFile* method, which has the same usage as\n`ioutil.ReadFile`_, is implemented for read-only access. Because base64 encoding\nis used, the size of the files will increase 33%.\n\n\nInstall\n+++++++\n\n.. code-block:: bash\n\n  $ go get -u github.com/siongui/goef\n\n\nUsage\n+++++\n\nAssume we have following directory structure:\n\n.. code-block:: txt\n\n  testdir/\n  ├── hello.txt\n  └── subdir/\n      └── hello2.txt\n\nWe want to embed the files in *testdir/* to our code, i.e., embed *hello.txt*\nand *subdir/hello2.txt* in our code, and the name of our package is *mypkg*. You\ncan embed the files as follows:\n\n.. code-block:: go\n\n  package main\n\n  import (\n  \t\"github.com/siongui/goef\"\n  )\n\n  func main() {\n  \terr := goef.GenerateGoPackage(\"mypkg\", \"testdir/\", \"data.go\")\n  \tif err != nil {\n  \t\tpanic(err)\n  \t}\n  }\n\nThe above code will generate *data.go* in current directory, which contains the\nfiles directly in the code. You can read embedded files with the following\nmethod:\n\n.. code-block:: go\n\n  func ReadFile(filename string) ([]byte, error)\n\nwhich has the same usage as `ioutil.ReadFile`_ in Go standard library. You can\nread *hello.txt* as follows:\n\n.. code-block:: go\n\n  b, err := ReadFile(\"hello.txt\")\n  if err != nil {\n  \t// handle error here\n  }\n\nAnd read *subdir/hello2.txt* as follows:\n\n.. code-block:: go\n\n  b, err := ReadFile(\"subdir/hello2.txt\")\n  if err != nil {\n  \t// handle error here\n  }\n\nNote that for files in sub-directory, you also have to include the path of\nsub-dir in the filename.\n\nGenerateGoPackage_ method supports embedding symbolic links. When the symlink\nare read, the content of the file where the symlink points to will be returned.\n\nIf the file does not exit, *os.ErrNotExist* error will be returned.\n\nYou can also put the generated *data.go* in a separate package, import and read\nembedded files in the same way.\n\nIf your files are plain texts, you can use GenerateGoPackagePlainText_ instead\nof *GenerateGoPackage*. It is the same except that the file content is stored\nin plain text instead of base64 format and no symlinks embedding, and the size\nwill not increase 33% because of base64 encoding.\n\nGenerateGoPackagePlainTextWithMaxFileSize_ is the same as\nGenerateGoPackagePlainText_ except the output file size cannot be over the given\nmax limit. This is useful for deploy your code on cloud services such as Google\nApp Engine because they usually limit the max size of a single file.\n\nFor more details, see test files `buildpkg_test.go \u003cbuildpkg_test.go\u003e`_ and\n`import_test.go \u003cimport_test.go\u003e`_.\n\n\nUNLICENSE\n+++++++++\n\nReleased in public domain. See UNLICENSE_.\n\n\nReferences\n++++++++++\n\n.. [1] | `GitHub - UnnoTed/fileb0x: simple customizable tool to embed files in go \u003chttps://github.com/UnnoTed/fileb0x\u003e`_\n       | `GitHub - jteeuwen/go-bindata: A small utility which generates Go code from any file. Useful for embedding binary data in a Go program. \u003chttps://github.com/jteeuwen/go-bindata\u003e`_\n       | `GitHub - elazarl/go-bindata-assetfs: Serves embedded files from \\`jteeuwen/go-bindata\\` with \\`net/http\\` \u003chttps://github.com/elazarl/go-bindata-assetfs\u003e`_\n       | `GitHub - GeertJohan/go.rice: go.rice is a Go package that makes working with resources such as html,js,css,images,templates, etc very easy. \u003chttps://github.com/GeertJohan/go.rice\u003e`_\n       | `GitHub - shurcooL/vfsgen: Takes an input http.FileSystem (likely at go generate time) and generates Go code that statically implements it. \u003chttps://github.com/shurcooL/vfsgen\u003e`_\n       | `GitHub - tv42/becky: Go asset embedding for use with \\`go generate\\` \u003chttps://github.com/tv42/becky\u003e`_\n       | `GitHub - rakyll/statik: Embed static files into a Go executable \u003chttps://github.com/rakyll/statik\u003e`_\n       | `GitHub - mjibson/esc: A simple file embedder for Go \u003chttps://github.com/mjibson/esc\u003e`_\n       | `GitHub - bouk/staticfiles: staticfiles compiles a directory of files into an embeddable .go file \u003chttps://github.com/bouk/staticfiles\u003e`_\n       | `GitHub - flazz/togo: convert any file to Go source \u003chttps://github.com/flazz/togo\u003e`_\n       | `GitHub - inconshreveable/go-update: Build self-updating Golang programs \u003chttps://github.com/inconshreveable/go-update\u003e`_\n       | `GitHub - aprice/embed: Static content embedding for Golang \u003chttps://github.com/aprice/embed\u003e`_\n       | `GitHub - gobuffalo/packr: The simple and easy way to embed static files into Go binaries. \u003chttps://github.com/gobuffalo/packr\u003e`_\n\n.. [2] | `Is including assets (with a tool like go-bindata) an anti-pattern? : golang \u003chttps://www.reddit.com/r/golang/comments/60166q/is_including_assets_with_a_tool_like_gobindata_an/\u003e`_\n       | `How to build Go plugin with data inside : golang \u003chttps://www.reddit.com/r/golang/comments/63f3ag/how_to_build_go_plugin_with_data_inside/\u003e`_\n       | `golang - compile static files in app? : golang \u003chttps://www.reddit.com/r/golang/comments/66uewv/golang_compile_static_files_in_app/\u003e`_\n       | `embed: Yet Another Static Content Embedder for Go : golang \u003chttps://www.reddit.com/r/golang/comments/6fh80b/embed_yet_another_static_content_embedder_for_go/\u003e`_\n       | `Embed libraries into exe : golang \u003chttps://www.reddit.com/r/golang/comments/7h9kcx/embed_libraries_into_exe/\u003e`_\n\n.. [3] `Embed Data in Front-end Go Code \u003chttps://siongui.github.io/2017/04/08/go-embed-data-in-frontend-code/\u003e`_\n\n.. [4] | `[Q\u0026A] //go:embed draft design : golang \u003chttps://old.reddit.com/r/golang/comments/hv96ny/qa_goembed_draft_design/\u003e`_\n       | `[Q\u0026A] io/fs draft design : golang \u003chttps://old.reddit.com/r/golang/comments/hv976o/qa_iofs_draft_design/\u003e`_\n\n\n.. _Go: https://golang.org/\n.. _GopherJS: https://github.com/gopherjs/gopherjs\n.. _base64: https://en.wikipedia.org/wiki/Base64\n.. _map: https://blog.golang.org/go-maps-in-action\n.. _ioutil.ReadFile: https://golang.org/pkg/io/ioutil/#ReadFile\n.. _UNLICENSE: http://unlicense.org/\n.. _GenerateGoPackage: https://godoc.org/github.com/siongui/goef#GenerateGoPackage\n.. _GenerateGoPackagePlainText: https://godoc.org/github.com/siongui/goef#GenerateGoPackagePlainText\n.. _GenerateGoPackagePlainTextWithMaxFileSize: https://godoc.org/github.com/siongui/goef#GenerateGoPackagePlainTextWithMaxFileSize\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiongui%2Fgoef","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsiongui%2Fgoef","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiongui%2Fgoef/lists"}