{"id":13413729,"url":"https://github.com/go-playground/statics","last_synced_at":"2025-05-05T17:31:49.910Z","repository":{"id":57487430,"uuid":"43812000","full_name":"go-playground/statics","owner":"go-playground","description":":file_folder: Embeds static resources into go files for single binary compilation + works with http.FileSystem + symlinks","archived":false,"fork":false,"pushed_at":"2016-10-05T01:27:05.000Z","size":53,"stargazers_count":67,"open_issues_count":0,"forks_count":7,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-25T05:24:36.568Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/go-playground.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-07T11:49:52.000Z","updated_at":"2024-09-23T11:03:16.000Z","dependencies_parsed_at":"2022-09-13T08:10:30.016Z","dependency_job_id":null,"html_url":"https://github.com/go-playground/statics","commit_stats":null,"previous_names":["joeybloggs/statics"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-playground%2Fstatics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-playground%2Fstatics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-playground%2Fstatics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-playground%2Fstatics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/go-playground","download_url":"https://codeload.github.com/go-playground/statics/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252542259,"owners_count":21764934,"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","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":[],"created_at":"2024-07-30T20:01:47.582Z","updated_at":"2025-05-05T17:31:49.657Z","avatar_url":"https://github.com/go-playground.png","language":"Go","funding_links":[],"categories":["Resource Embedding","嵌入的资源","资源嵌入","\u003cspan id=\"资源嵌入-resource-embedding\"\u003e资源嵌入 Resource Embedding\u003c/span\u003e","Relational Databases"],"sub_categories":["HTTP Clients","HTTP客户端","查询语","Advanced Console UIs","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e","交流"],"readme":"Package statics\n===============\n\n![Project status](https://img.shields.io/badge/version-1.7.0-green.svg)\n[![Build Status](https://semaphoreci.com/api/v1/projects/1b97afa9-77f3-43ff-ad26-749958500745/601363/badge.svg)](https://semaphoreci.com/joeybloggs/statics)\n[![Go Report Card](http://goreportcard.com/badge/go-playground/statics)](http://goreportcard.com/report/go-playground/statics)\n[![GoDoc](https://godoc.org/github.com/go-playground/statics/static?status.svg)](https://godoc.org/github.com/go-playground/statics/static)\n![License](https://img.shields.io/dub/l/vibe-d.svg)\n\nPackage statics embeds static files into your go applications. It provides helper methods and objects to retrieve embeded files and serve via http.\n\nIt has the following **unique** features:\n\n-   ```Follows Symlinks!``` uses the symlinked file/directory name and path but the contents and other fileinfo of the original file.\n-   Embeds static generation command for using ```go:generate``` in each static file for easy generation in production mode.\n-   Handles multiple static go files, even inside of the same package.\n-   Handles development (aka local files) vs production (aka static files) across packages.\n\nInstallation\n------------\n\n```shell\n\tgo get -u github.com/go-playground/statics\n```\n\nThen import the statics package into your own code.\n\n\timport \"github.com/go-playground/statics\"\n\nUsage and documentation\n------\n\nPlease see https://godoc.org/github.com/go-playground/statics/static for detailed usage docs.\n\nNOTE: when specifying path or directory name in code always use \"/\", even for you windows users,\n     the package handles any conversion to you local filesystem paths; Except for the AbsPkgPath\n     variable in the config.\n\nrun statics -h to see the options/arguments\n\n##### Examples:\n\nEmbedding in Source Control\n\nstatics -i=assets -o=assets.go -pkg=main -group=Assets -ignore=\\\\\\\\.gitignore -init=true\n\nOutput:\n```go\n//go:generate statics -i=assets -o=assets.go -pkg=main -group=Assets -ignore=\\.gitignore\n\npackage main\n\nimport \"github.com/go-playground/statics/static\"\n\n// newStaticAssets initializes a new *static.Files instance for use\nfunc newStaticAssets(config *static.Config) (*static.Files, error) {\n\n\treturn static.New(config, \u0026static.DirFile{})\n}\n```\n\nwhen using arg init=true statics package generates a minimal configuration with no \nfiles embeded; you can then add it to source control, ignore the file locally using\ngit update-index --assume-unchanged [filename(s)] and then when ready for generation \njust run go generate from the project root and the files will get embedded ready for \ncompilation.\n\nBe sure to check out this packages best buddy https://github.com/go-playground/generate\nto help get everything generated and ready for compilation.\n\nExample Usage\n```go\n// generated via command: \n// statics -i=assets -o=assets.go -pkg=main -group=Assets -ignore=//.gitignore\n\ngopath := getGopath() // retrieved from environment variable\npkgPath := \"/src/github.com/username/project\"\n\n// get absolute directory path of the -i arguments parent directory + any prefix \n// removed, used when UseStaticFiles=false this is so even when referencing this \n// package from another project and your PWD is not for this package anymore the \n// file paths will still work.\npkg := goapth + pkgPath\n\nconfig := \u0026static.Config{\n\tUseStaticFiles: true,\n\tAbsPkgPath:     pkg,\n}\n\n// NOTE: Assets in the function name below is the group in the generation command\nassets, err := newStaticAssets(config)\nif err != nil {\n\tlog.Println(err)\n}\n\n// when using http\nhttp.Handle(\"/assets\", http.FileServer(assets.FS()))\n\n// other methods for direct access\nassets.GetHTTPFile\nassets.ReadFile\nassets.ReadDir\nassets.ReadFiles\n```\n\nPackage Versioning\n----------\nI'm jumping on the vendoring bandwagon, you should vendor this package as I will not\nbe creating different version with gopkg.in like allot of my other libraries.\n\nWhy? because my time is spread pretty thin maintaining all of the libraries I have + LIFE,\nit is so freeing not to worry about it and will help me keep pouring out bigger and better\nthings for you the community.\n\nLicense\n------\nDistributed under MIT License, please see license file in code for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-playground%2Fstatics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgo-playground%2Fstatics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-playground%2Fstatics/lists"}