{"id":19304773,"url":"https://github.com/noneback/go-taskflow","last_synced_at":"2026-01-07T07:25:16.219Z","repository":{"id":226725348,"uuid":"767894250","full_name":"noneback/go-taskflow","owner":"noneback","description":"A pure go General-purpose Task-parallel Programming Framework with integrated visualizer and profiler","archived":false,"fork":false,"pushed_at":"2025-04-07T05:55:12.000Z","size":145,"stargazers_count":495,"open_issues_count":4,"forks_count":21,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-11T23:18:03.188Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/noneback.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":"2024-03-06T04:53:14.000Z","updated_at":"2025-04-11T14:04:25.000Z","dependencies_parsed_at":"2024-03-09T09:31:25.621Z","dependency_job_id":"d35609df-7dc3-4e17-8eab-954f620b1725","html_url":"https://github.com/noneback/go-taskflow","commit_stats":null,"previous_names":["noneback/go-taskflow"],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noneback%2Fgo-taskflow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noneback%2Fgo-taskflow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noneback%2Fgo-taskflow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noneback%2Fgo-taskflow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/noneback","download_url":"https://codeload.github.com/noneback/go-taskflow/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248492885,"owners_count":21113163,"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-11-09T23:31:34.007Z","updated_at":"2026-01-07T07:25:16.213Z","avatar_url":"https://github.com/noneback.png","language":"Go","readme":"# go-taskflow\n\n[![codecov](https://codecov.io/github/noneback/go-taskflow/graph/badge.svg?token=CITXYA10C6)](https://codecov.io/github/noneback/go-taskflow)\n[![Go Reference](https://pkg.go.dev/badge/github.com/noneback/go-taskflow.svg)](https://pkg.go.dev/github.com/noneback/go-taskflow)\n[![Go Report Card](https://goreportcard.com/badge/github.com/noneback/go-taskflow)](https://goreportcard.com/report/github.com/noneback/go-taskflow)\n[![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go)\n[![DeepWiki][deepwiki-image]][deepwiki-url]\n\n[deepwiki-url]: https://deepwiki.com/noneback/go-taskflow\n[deepwiki-image]: https://img.shields.io/badge/Chat%20with-DeepWiki%20🤖-20B2AA\n\n![go-taskflow](https://socialify.git.ci/noneback/go-taskflow/image?description=1\u0026language=1\u0026name=1\u0026pattern=Solid\u0026theme=Auto)\n\ngo-taskflow is a general-purpose task-parallel programming framework for Go, inspired by [taskflow-cpp](https://github.com/taskflow/taskflow). It leverages Go's native capabilities and simplicity, making it ideal for managing complex dependencies in concurrent tasks.\n\n## Features\n\n- **High Extensibility**: Easily extend the framework to adapt to various specific use cases.\n- **Native Go Concurrency Model**: Leverages Go's goroutines for efficient concurrent task execution.\n- **User-Friendly Programming Interface**: Simplifies complex task dependency management in Go.\n- **Static, Subflow, Conditional, and Cyclic Tasking**: Define static tasks, condition nodes, nested subflows, and cyclic flows to enhance modularity and programmability.\n\n    | Static | Subflow | Condition | Cyclic |\n    |:-----------|:------------:|------------:|------------:|\n    | ![](image/simple.svg)     |   ![](image/subflow.svg)   |      ![](image/condition.svg) |      ![](image/loop.svg) |\n\n- **Priority Task Scheduling**: Assign task priorities to ensure higher-priority tasks are executed first.\n- **Built-in Visualization and Profiling Tools**: Generate visual representations of tasks and profile task execution performance using integrated tools, simplifying debugging and optimization.\n\n## Use Cases\n\n- **Data Pipelines**: Orchestrate data processing stages with complex dependencies.\n- **AI Agent Workflow Automation**: Define and execute AI agent workflows with clear sequences and dependency structures.\n- **Parallel Graph Tasking**: Execute graph-based tasks concurrently to maximize CPU utilization.\n\n## Installation\n\nImport the latest version of go-taskflow using:\n\n```bash\ngo get -u github.com/noneback/go-taskflow\n```\n## Documentation\n[DeepWiki Page](https://deepwiki.com/noneback/go-taskflow)\n## Example\n\nBelow is an example of using go-taskflow to implement a parallel merge sort:\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"log\"\n    \"math/rand\"\n    \"os\"\n    \"slices\"\n    \"strconv\"\n    \"sync\"\n\n    gtf \"github.com/noneback/go-taskflow\"\n)\n\n// mergeInto merges a sorted source array into a sorted destination array.\nfunc mergeInto(dest, src []int) []int {\n    size := len(dest) + len(src)\n    tmp := make([]int, 0, size)\n    i, j := 0, 0\n    for i \u003c len(dest) \u0026\u0026 j \u003c len(src) {\n        if dest[i] \u003c src[j] {\n            tmp = append(tmp, dest[i])\n            i++\n        } else {\n            tmp = append(tmp, src[j])\n            j++\n        }\n    }\n\n    if i \u003c len(dest) {\n        tmp = append(tmp, dest[i:]...)\n    } else {\n        tmp = append(tmp, src[j:]...)\n    }\n\n    return tmp\n}\n\nfunc main() {\n    size := 100\n    randomArr := make([][]int, 10)\n    sortedArr := make([]int, 0, 10*size)\n    mutex := \u0026sync.Mutex{}\n\n    for i := 0; i \u003c 10; i++ {\n        for j := 0; j \u003c size; j++ {\n            randomArr[i] = append(randomArr[i], rand.Int())\n        }\n    }\n\n    sortTasks := make([]*gtf.Task, 10)\n    tf := gtf.NewTaskFlow(\"merge sort\")\n    done := tf.NewTask(\"Done\", func() {\n        if !slices.IsSorted(sortedArr) {\n            log.Fatal(\"Sorting failed\")\n        }\n        fmt.Println(\"Sorted successfully\")\n        fmt.Println(sortedArr[:1000])\n    })\n\n    for i := 0; i \u003c 10; i++ {\n        sortTasks[i] = tf.NewTask(\"sort_\"+strconv.Itoa(i), func() {\n            arr := randomArr[i]\n            slices.Sort(arr)\n            mutex.Lock()\n            defer mutex.Unlock()\n            sortedArr = mergeInto(sortedArr, arr)\n        })\n    }\n    done.Succeed(sortTasks...)\n\n    executor := gtf.NewExecutor(1000)\n\n    executor.Run(tf).Wait()\n\n    if err := tf.Dump(os.Stdout); err != nil {\n        log.Fatal(\"Error dumping taskflow:\", err)\n    }\n\n    if err := executor.Profile(os.Stdout); err != nil {\n        log.Fatal(\"Error profiling taskflow:\", err)\n    }\n}\n```\n\nFor more examples, visit the [examples directory](https://github.com/noneback/go-taskflow/tree/main/examples).\n\n## Benchmark\n\nThe following benchmark provides a rough estimate of performance. Note that most realistic workloads are I/O-bound, and their performance cannot be accurately reflected by these results. For CPU-intensive tasks, consider using [taskflow-cpp](https://github.com/taskflow/taskflow).\n\n```plaintext\n$ go test -bench=. -benchmem\ngoos: linux\ngoarch: amd64\npkg: github.com/noneback/go-taskflow/benchmark\ncpu: Intel(R) Xeon(R) Platinum 8269CY CPU @ 2.50GHz\nBenchmarkC32-4    \t   23282\t     51891 ns/op\t    7295 B/op\t     227 allocs/op\nBenchmarkS32-4    \t    7047\t    160199 ns/op\t    6907 B/op\t     255 allocs/op\nBenchmarkC6-4     \t   66397\t     18289 ns/op\t    1296 B/op\t      47 allocs/op\nBenchmarkC8x8-4   \t    7946\t    143474 ns/op\t   16914 B/op\t     504 allocs/op\nPASS\nok  \tgithub.com/noneback/go-taskflow/benchmark\t5.606s\n```\n\n## Understanding Conditional Tasks\n\nConditional nodes in go-taskflow behave similarly to those in [taskflow-cpp](https://github.com/taskflow/taskflow). They participate in both conditional control and looping. To avoid common pitfalls, refer to the [Conditional Tasking documentation](https://taskflow.github.io/taskflow/ConditionalTasking.html).\n\n## Error Handling in go-taskflow\n\nIn Go, `errors` are values, and it is the user's responsibility to handle them appropriately. Only unrecovered `panic` events are managed by the framework. If a `panic` occurs, the entire parent graph is canceled, leaving the remaining tasks incomplete. This behavior may evolve in the future. If you have suggestions, feel free to share them.\n\nTo prevent interruptions caused by `panic`, you can handle them manually when registering tasks:\n\n```go\ntf.NewTask(\"not interrupt\", func() {\n    defer func() {\n        if r := recover(); r != nil {\n            // Handle the panic.\n        }\n    }()\n    // User-defined logic.\n})\n```\n\n## Visualizing Taskflows\n\nTo generate a visual representation of a taskflow, use the `Dump` method:\n\n```go\nif err := tf.Dump(os.Stdout); err != nil {\n    log.Fatal(err)\n}\n```\n\nThe `Dump` method generates raw strings in DOT format. Use the `dot` tool to create a graph SVG. \n\n![dot](image/desc.svg)\n\n## Profiling Taskflows\n\nTo profile a taskflow, use the `Profile` method:\n\n```go\nif err := executor.Profile(os.Stdout); err != nil {\n    log.Fatal(err)\n}\n```\n\nThe `Profile` method generates raw strings in flamegraph format. Use the `flamegraph` tool to create a flamegraph SVG.\n\n![flg](image/fl.svg)\n\n## Stargazer\n\n[![Star History Chart](https://api.star-history.com/svg?repos=noneback/go-taskflow\u0026type=Date)](https://star-history.com/#noneback/go-taskflow\u0026Date)\n\n","funding_links":[],"categories":["Workflow Frameworks","Library (embedded usage)"],"sub_categories":["Routers","Utility/Miscellaneous","路由器"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoneback%2Fgo-taskflow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnoneback%2Fgo-taskflow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoneback%2Fgo-taskflow/lists"}