{"id":17242512,"url":"https://github.com/mstryoda/gommons","last_synced_at":"2025-07-21T03:10:00.401Z","repository":{"id":64111565,"uuid":"573110632","full_name":"mstrYoda/gommons","owner":"mstrYoda","description":"Swiss army knife for Golang developers","archived":false,"fork":false,"pushed_at":"2023-06-07T12:37:37.000Z","size":15,"stargazers_count":74,"open_issues_count":0,"forks_count":9,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-02-27T23:05:46.321Z","etag":null,"topics":["cmd","concurrency","go","golang","gopher","library","unsafe","utils"],"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/mstrYoda.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}},"created_at":"2022-12-01T18:10:50.000Z","updated_at":"2025-02-15T20:03:34.000Z","dependencies_parsed_at":"2024-06-19T17:37:07.708Z","dependency_job_id":"adee7151-c39d-452e-95c6-be8b9a270427","html_url":"https://github.com/mstrYoda/gommons","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mstrYoda%2Fgommons","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mstrYoda%2Fgommons/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mstrYoda%2Fgommons/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mstrYoda%2Fgommons/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mstrYoda","download_url":"https://codeload.github.com/mstrYoda/gommons/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243858056,"owners_count":20359271,"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":["cmd","concurrency","go","golang","gopher","library","unsafe","utils"],"created_at":"2024-10-15T06:13:26.065Z","updated_at":"2025-03-17T11:30:32.054Z","avatar_url":"https://github.com/mstrYoda.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gommons\n\nSwiss army knife for Golang developers\n\n## Features\n\n- [X] Async tasks\n- [X] Async tasks with results\n- [X] Async Pub/Sub Queue\n- [X] Command exec utils\n- [X] Zero alloc string-byte conversion\n- [X] Function execution elapsed time util\n- [ ] Time utils\n- [ ] Array utils\n\n\u003cdetails\u003e\n\u003csummary\u003eAsync\u003c/summary\u003e\n\n#### Async tasks\n\n```go\nNew().Task(\n    func () {\n        a = 1\n        fmt.Println(\"1\")\n    }, func () {\n        b = 1\n        fmt.Println(\"2\")\n    }).Await()\n```\n\n#### Async tasks with results\n\n```go\nresults := NewAsyncWorkWithResult[int]().TaskWithResult(\n    func() int {\n        return 5\n    }, func() int {\n        return 11\n    }).AwaitResult()\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eQueue Pub/Sub example\u003c/summary\u003e\n\nQueue acts as a non-blocking message queue backing with unbuffered channel.\nPublish/Subscribe functions are not blocks code execution.\n\n```go\nq := NewQueue[int]()\nq.Publish(context.Background(), 1)\nq.Publish(context.Background(), 2)\n\nq.Subscribe(context.Background(), func(data int) {\n\tfmt.Println(\"data readed \", data)\n})\n\n\u003c-make(chan struct{})\n```\n\nYou can also give timeout to both message publish and subscribe functions:\n\n```go\nq := NewQueue[int]()\nctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)\ndefer cancel()\nq.Publish(context.Background(), 1)\nq.Publish(ctx, 2)\n\nq.Subscribe(ctx, func(data int) {\n\tfmt.Println(\"data readed \", data)\n})\n\n\u003c-make(chan struct{})\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eCommand exec\u003c/summary\u003e\n\n#### Run posix command and get output as byte array\n\n```go\nout := Exec(\"echo\", \"test\")\n```\n\n#### Run posix command with pipes\n\n```go\nstrReader := strings.NewReader(\"hello world\")\n\noutWriter := bytes.NewBuffer(nil)\nerrWriter := bytes.NewBuffer(nil)\n\nExecPipe(strReader, outWriter, errWriter, \"echo\", \"test\")\noutputStr := outWriter.String()\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eZero alloc string byte conversion\u003c/summary\u003e\n\n#### String to byte array zero allocation\n\n```go\nstr := String([]byte(\"test\"))\n```\n#### Byte to string\n\n```go\nbyteArr := Byte(\"test\")\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eTime utils\u003c/summary\u003e\n\n#### Function execution elapsed time utility\n\n```go\nelapsedTime := ElapsedTime(func() {\n\ttime.Sleep(100 * time.Millisecond)\n})\n```\n\t\n\n\u003c/details\u003e\n\n\n## Getting All Dependencies\n### To get all Dependencies in project run `go mod tidy` in root of project\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmstryoda%2Fgommons","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmstryoda%2Fgommons","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmstryoda%2Fgommons/lists"}