{"id":42397000,"url":"https://github.com/stcrestrada/gogo","last_synced_at":"2026-01-28T01:01:45.418Z","repository":{"id":55439375,"uuid":"325650907","full_name":"stcrestrada/gogo","owner":"stcrestrada","description":"Manage goroutines and worker pools with ease. Chain them to create complex processing pipelines.","archived":false,"fork":false,"pushed_at":"2025-03-21T23:13:31.000Z","size":43,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-22T00:19:09.277Z","etag":null,"topics":["concurrency","concurrent-safe","go","goroutines"],"latest_commit_sha":null,"homepage":"https://github.com/stcrestrada/gogo","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/stcrestrada.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":"2020-12-30T21:24:49.000Z","updated_at":"2025-03-21T23:04:08.000Z","dependencies_parsed_at":"2025-03-22T00:29:10.010Z","dependency_job_id":null,"html_url":"https://github.com/stcrestrada/gogo","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/stcrestrada/gogo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stcrestrada%2Fgogo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stcrestrada%2Fgogo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stcrestrada%2Fgogo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stcrestrada%2Fgogo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stcrestrada","download_url":"https://codeload.github.com/stcrestrada/gogo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stcrestrada%2Fgogo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28831147,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T23:29:49.665Z","status":"ssl_error","status_checked_at":"2026-01-27T23:25:58.379Z","response_time":168,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":["concurrency","concurrent-safe","go","goroutines"],"created_at":"2026-01-28T01:01:38.862Z","updated_at":"2026-01-28T01:01:45.342Z","avatar_url":"https://github.com/stcrestrada.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gogo\n\n[![Go](https://github.com/stcrestrada/gogo/actions/workflows/go.yml/badge.svg)](https://github.com/stcrestrada/gogo/actions/workflows/go.yml)\n\nSimple Golang package for async goroutines with pools (workers/semaphores).\n\n## Features\n\n- Simple async function wrapping via `Go` and `GoVoid` functions\n- Typed results via generics\n- Concurrent goroutine pools with controlled concurrency limits\n- Pipeline-style chaining of goroutine pools\n- Context support for proper cancellation and timeout handling\n- Easy cancellation of in-progress operations\n\n## Installation\n\n```\ngo get github.com/stcrestrada/gogo\n```\n\n## Basic Usage\n\n### Simple Async Function\n\n```go\nimport (\n    \"context\"\n    \"github.com/stcrestrada/gogo\"\n)\n\n// Create a context\nctx := context.Background()\n\n// Launch in another goroutine (non-blocking)\nproc := gogo.Go(ctx, func(ctx context.Context) (*http.Response, error) {\n    req, err := http.NewRequestWithContext(ctx, \"GET\", \"https://example.com\", nil)\n    if err != nil {\n        return nil, err\n    }\n    return http.DefaultClient.Do(req)\n})\n\n// Do other work...\n\n// Later, wait for results (blocking, concurrency safe)\nres, err := proc.Result()\n```\n\n### Goroutine Pools with Controlled Concurrency\n\n```go\n// Create a context\nctx := context.Background()\n\n// Set up a pool with 2 concurrent goroutines for 5 URLs\nurls := []string{\"https://example1.com\", \"https://example2.com\", \"https://example3.com\", \"https://example4.com\", \"https://example5.com\"}\n\npool := gogo.NewPool(ctx, 2, len(urls), func(i int) func(ctx context.Context) (*http.Response, error) {\n    url := urls[i]\n    return func(ctx context.Context) (*http.Response, error) {\n        req, err := http.NewRequestWithContext(ctx, \"GET\", url, nil)\n        if err != nil {\n            return nil, err\n        }\n        return http.DefaultClient.Do(req)\n    }\n})\n\n// Get a channel feed of results\nfeed := pool.Go()\n\n// Process results as they come in\nfor res := range feed {\n    if res.Error != nil {\n        fmt.Printf(\"Error: %v\\n\", res.Error)\n        continue\n    }\n    fmt.Printf(\"Got response from %s: %d\\n\", res.Result.Request.URL, res.Result.StatusCode)\n}\n```\n\n### Context Cancellation\n\n```go\n// Create a context with timeout\nctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)\ndefer cancel()\n\npool := gogo.NewPool(ctx, 2, 10, func(i int) func(ctx context.Context) (string, error) {\n    return func(ctx context.Context) (string, error) {\n        select {\n        case \u003c-ctx.Done():\n            return \"\", ctx.Err()\n        case \u003c-time.After(2 * time.Second):\n            return fmt.Sprintf(\"Task %d completed\", i), nil\n        }\n    }\n})\n\nfeed := pool.Go()\n\n// Read results as they come in\nfor res := range feed {\n    if res.Error != nil {\n        fmt.Printf(\"Error: %v\\n\", res.Error) // Will include context.DeadlineExceeded errors\n    } else {\n        fmt.Printf(\"Result: %s\\n\", res.Result)\n    }\n}\n```\n\n### Manual Cancellation\n\n```go\nctx := context.Background()\n\npool := gogo.NewPool(ctx, 2, 10, func(i int) func(ctx context.Context) (string, error) {\n    return func(ctx context.Context) (string, error) {\n        // Check for cancellation\n        select {\n        case \u003c-ctx.Done():\n            return \"\", ctx.Err()\n        default:\n            // Continue with work\n        }\n        \n        // Do work\n        return fmt.Sprintf(\"Task %d\", i), nil\n    }\n})\n\nfeed := pool.Go()\n\n// Some condition to cancel the pool\nif someCondition {\n    pool.Cancel() // This will cancel all in-progress and pending tasks\n}\n\n// Process remaining results (including cancellation errors)\nfor res := range feed {\n    // Handle results\n}\n```\n\n## Advanced Usage\n\n### Chained Pools (Pipeline)\n\n```go\nctx := context.Background()\nrequestConcurrency := 2\nprocessingConcurrency := 8\nurls := []string{\"https://example1.com\", \"https://example2.com\", \"https://example3.com\"}\n\n// Start request group\nrequestGroup := gogo.NewPool(ctx, requestConcurrency, len(urls), func(i int) func(ctx context.Context) (*http.Response, error) {\n    url := urls[i]\n    return func(ctx context.Context) (*http.Response, error) {\n        req, err := http.NewRequestWithContext(ctx, \"GET\", url, nil)\n        if err != nil {\n            return nil, err\n        }\n        return http.DefaultClient.Do(req)\n    }\n})\nrequestFeed := requestGroup.Go()\n\n// Start processing group and pipe in request results\nprocessingGroup := gogo.NewPool(ctx, processingConcurrency, len(urls), func(i int) func(ctx context.Context) (*http.Response, error) {\n    requestResult := \u003c-requestFeed\n    return func(ctx context.Context) (*http.Response, error) {\n        if requestResult.Error != nil {\n            return nil, requestResult.Error\n        }\n        // Process the response\n        return requestResult.Result, nil\n    }\n})\n\n// Wait for the pipeline to finish\nprocessingGroup.Wait()\n```\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstcrestrada%2Fgogo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstcrestrada%2Fgogo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstcrestrada%2Fgogo/lists"}