{"id":19600465,"url":"https://github.com/shurcool/goexec","last_synced_at":"2025-04-05T10:09:08.108Z","repository":{"id":8287261,"uuid":"9825564","full_name":"shurcooL/goexec","owner":"shurcooL","description":"A command line tool to execute Go functions.","archived":false,"fork":false,"pushed_at":"2023-11-26T04:03:32.000Z","size":35,"stargazers_count":384,"open_issues_count":2,"forks_count":10,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-03-29T09:10:07.796Z","etag":null,"topics":["go"],"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/shurcooL.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":"2013-05-03T00:32:40.000Z","updated_at":"2025-03-17T14:57:10.000Z","dependencies_parsed_at":"2024-06-18T15:43:17.709Z","dependency_job_id":null,"html_url":"https://github.com/shurcooL/goexec","commit_stats":{"total_commits":71,"total_committers":2,"mean_commits":35.5,"dds":0.09859154929577463,"last_synced_commit":"96bada04ea2b9d03f88571e2bc3347027da483fb"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shurcooL%2Fgoexec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shurcooL%2Fgoexec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shurcooL%2Fgoexec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shurcooL%2Fgoexec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shurcooL","download_url":"https://codeload.github.com/shurcooL/goexec/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247318745,"owners_count":20919484,"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":["go"],"created_at":"2024-11-11T09:14:54.167Z","updated_at":"2025-04-05T10:09:08.077Z","avatar_url":"https://github.com/shurcooL.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"goexec\n======\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/shurcooL/goexec.svg)](https://pkg.go.dev/github.com/shurcooL/goexec)\n\ngoexec is a command line tool to execute Go code. Output is printed as goons to stdout.\n\nInstallation\n------------\n\n```sh\ngo install github.com/shurcooL/goexec@latest\n```\n\nUsage\n-----\n\n```\nUsage: goexec [flags] [packages] [package.]function(parameters)\n       echo parameters | goexec -stdin [flags] [packages] [package.]function\n  -compiler string\n    \tCompiler to use, one of: \"gc\", \"gopherjs\". (default \"gc\")\n  -n\tPrint the generated source but do not run it.\n  -quiet\n    \tDo not dump the return values as a goon.\n  -stdin\n    \tRead func parameters from stdin instead.\n  -tags string\n    \tA comma-separated list of build tags to consider satisfied during the build.\n```\n\nExamples\n--------\n\n```sh\n$ goexec 'strings.Repeat(\"Go! \", 5)'\n(string)(\"Go! Go! Go! Go! Go! \")\n\n$ goexec strings 'Replace(\"Calling Go functions from the terminal is hard.\", \"hard\", \"easy\", -1)'\n(string)(\"Calling Go functions from the terminal is easy.\")\n\n# Note that parser.ParseExpr returns 2 values (ast.Expr, error).\n$ goexec 'parser.ParseExpr(\"5 + 7\")'\n(*ast.BinaryExpr)(\u0026ast.BinaryExpr{\n\tX: (*ast.BasicLit)(\u0026ast.BasicLit{\n\t\tValuePos: (token.Pos)(1),\n\t\tKind:     (token.Token)(5),\n\t\tValue:    (string)(\"5\"),\n\t}),\n\tOpPos: (token.Pos)(3),\n\tOp:    (token.Token)(12),\n\tY: (*ast.BasicLit)(\u0026ast.BasicLit{\n\t\tValuePos: (token.Pos)(5),\n\t\tKind:     (token.Token)(5),\n\t\tValue:    (string)(\"7\"),\n\t}),\n})\n(interface{})(nil)\n\n# Run function RepoRootForImportPath from package \"golang.org/x/tools/go/vcs\".\n$ goexec 'vcs.RepoRootForImportPath(\"rsc.io/pdf\", false)'\n(*vcs.RepoRoot)(...)\n(interface{})(nil)\n\n$ goexec -quiet 'fmt.Println(\"Use -quiet to disable output of goon; useful if you want to print to stdout.\")'\nUse -quiet to disable output of goon; useful if you want to print to stdout.\n\n$ echo '\"fmt\"' | goexec -stdin 'gist4727543.GetForcedUse'\n(string)(\"var _ = fmt.Errorf\")\n```\n\nAlternatives\n------------\n\n-\t[gommand](https://github.com/sno6/gommand) - Go one liner program, similar to python -c.\n-\t[gorram](https://github.com/natefinch/gorram) - Like go run for any Go function.\n-\t[goeval](https://github.com/dolmen-go/goeval) - Run Go snippets instantly from the command-line.\n\nLicense\n-------\n\n-\t[MIT License](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshurcool%2Fgoexec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshurcool%2Fgoexec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshurcool%2Fgoexec/lists"}