{"id":29117191,"url":"https://github.com/edwingeng/hotswap","last_synced_at":"2026-01-14T22:06:08.358Z","repository":{"id":42133029,"uuid":"375861624","full_name":"edwingeng/hotswap","owner":"edwingeng","description":"A complete solution to reload your go code without restarting your server, interrupting or blocking any ongoing procedure.","archived":false,"fork":false,"pushed_at":"2024-05-24T00:45:14.000Z","size":306,"stargazers_count":397,"open_issues_count":0,"forks_count":46,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-06-29T11:14:17.748Z","etag":null,"topics":["golang","hot-reload","hot-swap","hotswap","plugin"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/edwingeng.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-11T00:22:07.000Z","updated_at":"2025-06-20T03:54:47.000Z","dependencies_parsed_at":"2024-02-25T16:27:01.586Z","dependency_job_id":"9b18a044-1293-43c9-8cbe-b638576600da","html_url":"https://github.com/edwingeng/hotswap","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/edwingeng/hotswap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edwingeng%2Fhotswap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edwingeng%2Fhotswap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edwingeng%2Fhotswap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edwingeng%2Fhotswap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/edwingeng","download_url":"https://codeload.github.com/edwingeng/hotswap/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edwingeng%2Fhotswap/sbom","scorecard":{"id":367622,"data":{"date":"2025-08-11","repo":{"name":"github.com/edwingeng/hotswap","commit":"cb7c6779d058ebcd72551d2bd6d86caf9a3f5390"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"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":"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":"Dangerous-Workflow","score":-1,"reason":"no workflows found","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":"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":"Code-Review","score":0,"reason":"Found 1/29 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":"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":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"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":"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: LICENSE:0","Info: FSF or OSI recognized license: BSD 3-Clause \"New\" or \"Revised\" License: LICENSE: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 'main'"],"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"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 2 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-18T12:14:21.318Z","repository_id":42133029,"created_at":"2025-08-18T12:14:21.318Z","updated_at":"2025-08-18T12:14:21.318Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28436268,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T21:32:52.117Z","status":"ssl_error","status_checked_at":"2026-01-14T21:32:33.442Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["golang","hot-reload","hot-swap","hotswap","plugin"],"created_at":"2025-06-29T11:14:05.370Z","updated_at":"2026-01-14T22:06:08.335Z","avatar_url":"https://github.com/edwingeng.png","language":"Go","readme":"![Banner](imgs/banner.jpg?raw=true \"Hotswap\")\n\n[简体中文版](./README.zh-CN.md)\n\n*`Hotswap`* provides you a complete solution to reload your `go` code without restarting your server, interrupting or blocking any ongoing procedure. *`Hotswap`* is built upon the plugin mechanism.\n\n# Major Features\n\n- Reload your code like a breeze\n- Run different versions of a plugin in complete isolation\n- Use the hierarchical package structure as usual\n- Invoke an in-plugin function from its host program with `Plugin.InvokeFunc()`\n- Expose in-plugin data and functions with `PluginManager.Vault.Extension` and/or `PluginManager.Vault.DataBag`\n- Handle asynchronous jobs using the latest code with `live function`, `live type`, and `live data`\n- Link plugins statically for easy debugging\n- Expose functions to other plugins with `Export()`\n- Depend on other plugins with `Import()`\n\n# Getting Started\n\n```\ngo install github.com/edwingeng/hotswap/cli/hotswap@latest\n```\n\n# Build a Plugin from Source Code\n\n```\nUsage:\n  hotswap build [flags] \u003cpluginDir\u003e \u003coutputDir\u003e -- [buildFlags]\n\nExamples:\nhotswap build plugin/foo bin\nhotswap build -v plugin/foo bin -- -race\nhotswap build --staticLinking plugin/foo plugin\n\nFlags:\n      --debug               enable debug mode\n      --exclude string      go-regexp matching files to exclude from included\n      --goBuild             if --goBuild=false, skip the go build procedure (default true)\n  -h, --help                help for build\n      --include string      go-regexp matching files to include in addition to .go files\n      --leaveTemps          do not delete temporary files\n      --livePrefix string   case-insensitive name prefix of live functions and live types (default \"live_\")\n      --staticLinking       generate code for static linking instead of building a plugin\n  -v, --verbose             enable verbose mode\n```\n\n# Demos\n\nYou can find these examples under the `demo` directory. To have a direct experience, start a server with `run.sh` and reload its plugin(s) with `reload.sh`.\n\n1. `hello` demonstrates the basic usage, including how to organize host and plugin, how to build them, how to load plugin on server startup, how to use `InvokeEach`, and how to reload.\n2. `extension` shows how to define a custom extension and how to use `PluginManager.Vault.Extension`. A small hint: `WithExtensionNewer()`\n3. `livex` is somewhat complex. It shows how to work with `live function`, `live type`, and `live data`.\n4. `slink` is an example of plugin static-linking, with which debugging a plugin with a debugger (delve) under MacOS and Windows becomes possible.\n5. `trine` is the last example. It demonstrates the plugin dependency mechanism.\n\n# Required Functions\n\nA plugin must have the following functions defined in its root package.\n\n``` go\n// OnLoad gets called after all plugins are successfully loaded and before the Vault is initialized.\nfunc OnLoad(data interface{}) error {\n    return nil\n}\n\n// OnInit gets called after the execution of all OnLoad functions. The Vault is ready now.\nfunc OnInit(sharedVault *vault.Vault) error {\n    return nil\n}\n\n// OnFree gets called at some time after a reload.\nfunc OnFree() {\n}\n\n// Export returns an object to export to other plugins.\nfunc Export() interface{} {\n    return nil\n}\n\n// Import returns an object indicating the dependencies of the plugin.\nfunc Import() interface{} {\n    return nil\n}\n\n// InvokeFunc invokes the specified function.\nfunc InvokeFunc(name string, params ...interface{}) (interface{}, error) {\n    return nil, nil\n}\n\n// Reloadable indicates whether the plugin is reloadable.\nfunc Reloadable() bool {\n    return true\n}\n```\n\n# Order of Execution during Plugin Reload\n\n```\n1. Reloadable\n2. Export\n3. Import\n4. OnLoad\n5. Vault Initialization\n6. OnInit\n```\n\n# Attentions\n\n- Build your host program with the environmental variable `CGO_ENABLED=1` and the `-trimpath` flag.\n- Do **not** define any global variable in a reloadable plugin unless it can be discarded at any time or it actually never changes.\n- Do **not** create any long-running goroutine in a plugin, it's error-prone.\n- The same type in different versions of a plugin are actually **not** the same at runtime. Use `live function`, `live type`, and `live data` to avoid the trap.\n- The code of your host program should **never** import any package of any plugin and the code of a plugin should **never** import any package of other plugins.\n- Old versions won't be removed from the memory due to the limitation of golang plugin. However, *`Hotswap`* offers you a chance, the `OnFree` function, to clear caches.\n- It is required to manage your code with `git` and `go module`.\n- It is highly recommended to keep the code of your host program and all its plugins in a same repository.\n\n# Live Things\n\n- `live function` is a type of function whose name is prefixed with `live_` (case-insensitive). Live functions are automatically collected and stored in `PluginManager.Vault.LiveFuncs`. For example:\n``` go\nfunc live_Foo(jobData live.Data) error {\n      return nil\n}\n```\n- `live type` is a type of struct whose name is prefixed with `live_` (case-insensitive). Live types are automatically collected and stored in `PluginManager.Vault.LiveTypes`. For example:\n``` go\ntype Live_Bar struct {\n      N int\n}\n```\n- [`live data`](https://github.com/edwingeng/live) is a type guardian. You can convert your data into a `live data` object when scheduling an asynchronous job and restore your data from the `live data` object when handling the job.\n- See the demo `livex` for details.\n\n# FAQ\n\n- **How can I debug a plugin with a debugger?**\n\nBuild it with `--staticLink`. For more information, please refer to the demo `slink`.\n\n- **Does `hotswap` work on Windows?**\n\nBuilding with `--staticLink` works on Windows, but plugin reloading is not an option because Go's plugin mechanism doesn't support Windows.\n\n\n\u0026nbsp;\u003cbr/\u003e\n\u0026nbsp;\u003cbr/\u003e\n\u0026nbsp;\u003cbr/\u003e\n\u0026nbsp;\u003cbr/\u003e\n\u0026nbsp;\u003cbr/\u003e\n\u0026nbsp;\u003cbr/\u003e\n\u0026nbsp;\u003cbr/\u003e\n\u0026nbsp;\u003cbr/\u003e\n\u0026nbsp;\u003cbr/\u003e\n\u0026nbsp;\u003cbr/\u003e\n\u0026nbsp;\u003cbr/\u003e\n\u0026nbsp;\u003cbr/\u003e\n\u0026nbsp;\u003cbr/\u003e\n\u0026nbsp;\u003cbr/\u003e\n\u0026nbsp;\u003cbr/\u003e\n\u0026nbsp;\u003cbr/\u003e\n\u0026nbsp;\u003cbr/\u003e\n\u0026nbsp;\u003cbr/\u003e\n\u0026nbsp;\u003cbr/\u003e\n\u0026nbsp;\u003cbr/\u003e\n","funding_links":[],"categories":["Software Packages","软件包","Go Tools","Go"],"sub_categories":["Other Software","其他软件"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedwingeng%2Fhotswap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fedwingeng%2Fhotswap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedwingeng%2Fhotswap/lists"}