{"id":43927107,"url":"https://github.com/zcag/goscript","last_synced_at":"2026-02-06T23:09:19.047Z","repository":{"id":331690680,"uuid":"1131757998","full_name":"zcag/goscript","owner":"zcag","description":"Go scripting, write single file executable, run compiled. Shebang magic.","archived":false,"fork":false,"pushed_at":"2026-01-18T11:20:38.000Z","size":7309,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-18T18:36:22.702Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zcag.png","metadata":{"files":{"readme":"README.md","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-10T16:32:21.000Z","updated_at":"2026-01-18T11:20:42.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/zcag/goscript","commit_stats":null,"previous_names":["zcag/goscript"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zcag/goscript","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zcag%2Fgoscript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zcag%2Fgoscript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zcag%2Fgoscript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zcag%2Fgoscript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zcag","download_url":"https://codeload.github.com/zcag/goscript/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zcag%2Fgoscript/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29179641,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-06T22:12:24.066Z","status":"ssl_error","status_checked_at":"2026-02-06T22:12:09.859Z","response_time":59,"last_error":"SSL_read: 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":[],"created_at":"2026-02-06T23:09:18.507Z","updated_at":"2026-02-06T23:09:19.042Z","avatar_url":"https://github.com/zcag.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# goscript\n\nRun small, standalone Go scripts without creating a module or repository.\nSupports importing **any** go module, no `go.mod` required.\n\nYou write a single executable file with a shebang, and run it like a script.\n\n## Usage\n\n### Shebang Example\n\n```go\n#!/usr/bin/env goscript\npackage main\n\nimport (\n\t\"fmt\" // You don't have to define stdlibs\n\t\"os\"\n    \"github.com/pkg/errors\" // These deps are automatically installed\n)\n\nfunc main() {\n\tfmt.Println(\"args:\", os.Args[1:])\n    fmt.Println(errors.New(\"boom\"))\n}\n```\n\n```bash\nchmod +x myscript\n./myscript a b c\n```\n\nYou can create a binary from this singular goscript\n```bash\ngoscript -o mybin myscript\n./mybin a b c\n```\n\n### Inline Example\n\nYou can also run goscript directly with `goscript -c` to run go from the param directly.\nIt automagically handles packages/imports for you.\n\nThis feature also benefits from cached binaries, so it actually runs compiled binaries after running it at least once\n\n```bash\ngoscript -c 'fmt.Println(\"yeye\")'\n````\n\nThis can be combined with `-o` to compile a binary from your inline go command.\nNot sure why you would do this, but it's possible.\n\n```bash\ngoscript -o mybin -c 'fmt.Println(\"why\")'\n./mybin\n```\n\n## Installation\n\n```bash\ngo install zcag/goscript@latest\n```\nMake sure $GOPATH/bin (or $HOME/go/bin) is in your PATH.\n\n## How it works\n\n1. Script is executed via shebang (`#!/usr/bin/env goscript`)\n2. `goscript` reads the script file and hashes its raw contents\n3. Cache is checked under `~/.cache/goscript`\n4. On cache miss:\n   * shebang line is stripped\n   * any missing imports are added to the script\n   * script is written as `main.go` into a cache work directory\n   * go.mod is generated with all external dependencies\n   * Dependencies are installed\n   * a binary is built and stored in the cache\n5. The cached binary is executed\n\nSubsequent runs reuse the cached binary.\n\n## Requirements\n\n* Scripts must use `package main`\n* Scripts must define `func main()`\n\nThis is real Go code — no DSL, no auto-wrapping.\n\n## Cache layout\n\n```\n~/.cache/goscript/\n├── bin/\n│   └── \u003chash\u003e/app\n└── work/\n    └── \u003chash\u003e\n        ├── main.go\n        └── go.mod\n```\n\nCache key is currently based on the raw script contents.\n\n## TODO\n* add some helper methods to inline, to ease common pipe/arg handling and printing\n* supoort auto importing non standart libraries\n    * maybe have a big map of common libs\n* faster exec (`syscall.Exec`)\n    * support/test passing stdout to ./myscript.go\n* `goscript --migrate myscript.go myproj/` to convert script to proper go project\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzcag%2Fgoscript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzcag%2Fgoscript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzcag%2Fgoscript/lists"}