{"id":17041709,"url":"https://github.com/xlab/invoker","last_synced_at":"2025-03-23T01:21:11.338Z","repository":{"id":57529173,"uuid":"257076884","full_name":"xlab/invoker","owner":"xlab","description":"Supercharged \"exec.Cmd\" helpers for asynchronous and thread-safe reading of StdOut and StdErr.","archived":false,"fork":false,"pushed_at":"2022-09-24T17:51:20.000Z","size":6,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-28T04:31:18.485Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/xlab.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":"2020-04-19T18:48:04.000Z","updated_at":"2023-01-07T06:57:47.000Z","dependencies_parsed_at":"2022-09-18T04:40:22.065Z","dependency_job_id":null,"html_url":"https://github.com/xlab/invoker","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xlab%2Finvoker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xlab%2Finvoker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xlab%2Finvoker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xlab%2Finvoker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xlab","download_url":"https://codeload.github.com/xlab/invoker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245041815,"owners_count":20551469,"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-10-14T09:13:18.264Z","updated_at":"2025-03-23T01:21:11.301Z","avatar_url":"https://github.com/xlab.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## invoker [![Go Report Card](https://goreportcard.com/badge/github.com/xlab/invoker)](https://goreportcard.com/report/github.com/xlab/invoker) [![GoDoc](https://godoc.org/github.com/xlab/invoker?status.svg)](https://godoc.org/github.com/xlab/invoker)\n\nA package providing supercharged primitive for `exec.Cmd` that redirects StdErr and StdOut for asynchronous and thread-safe reading.\n\n### Example\n\n```go\nreturn func(ctx *gin.Context) {\n    out := invoker.Run(ctx, \"list\", \"-fmt\", \"json\")\n    defer func() {\n        go invoker.DrainOut(out)\n    }()\n\n    select {\n    case \u003c-ctx.Done():\n        ctx.AbortWithStatus(504)\n        return\n    case r := \u003c-out:\n        if r.Error != nil {\n            ctx.String(500, \"%+v\", r.Error)\n            return\n        }\n\n        ctx.Data(200, \"application/json\", r.StdOut())\n    }\n}\n```\n\n### Redirect to your logging\n\n```go\nctx := context.Background()\n\nlogFn := func(data []byte) (stop bool) {\n    logger.Info(\"Output:\", string(data))\n    return\n}\n\nstdErr := invoker.NewWatchedSafeBuffer(ctx, logFn, nil)\n\nout := invoker.RunWithIO(ctx, nil, nil, stdErr, \"list\", \"-fmt\", \"json\")\n\ngo invoker.DrainOut(out)\n```\n\n### License\n\n[MIT](/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxlab%2Finvoker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxlab%2Finvoker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxlab%2Finvoker/lists"}