{"id":30670539,"url":"https://github.com/backendarchitect/forge","last_synced_at":"2025-09-01T02:11:13.543Z","repository":{"id":312049079,"uuid":"1046089304","full_name":"backendArchitect/forge","owner":"backendArchitect","description":"Evokes the idea of building or crafting golang software.","archived":false,"fork":false,"pushed_at":"2025-08-28T13:26:28.000Z","size":25,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-28T14:08:36.158Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/backendArchitect.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,"zenodo":null}},"created_at":"2025-08-28T07:06:32.000Z","updated_at":"2025-08-28T13:14:04.000Z","dependencies_parsed_at":"2025-08-28T14:08:43.946Z","dependency_job_id":null,"html_url":"https://github.com/backendArchitect/forge","commit_stats":null,"previous_names":["backendarchitect/forge"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/backendArchitect/forge","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/backendArchitect%2Fforge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/backendArchitect%2Fforge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/backendArchitect%2Fforge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/backendArchitect%2Fforge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/backendArchitect","download_url":"https://codeload.github.com/backendArchitect/forge/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/backendArchitect%2Fforge/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273064985,"owners_count":25039267,"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","status":"online","status_checked_at":"2025-09-01T02:00:09.058Z","response_time":120,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2025-09-01T02:11:10.982Z","updated_at":"2025-09-01T02:11:13.537Z","avatar_url":"https://github.com/backendArchitect.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# forge - A Modular Go Utility Library\n\n[![CI](https://github.com/backendArchitect/forge/actions/workflows/ci.yml/badge.svg)](https://github.com/backendArchitect/forge/actions/workflows/ci.yml)\n[![Go Reference](https://pkg.go.dev/badge/github.com/backendArchitect/forge.svg)](https://pkg.go.dev/github.com/backendArchitect/forge)\n[![Go Report Card](https://goreportcard.com/badge/github.com/backendArchitect/forge)](https://goreportcard.com/report/github.com/backendArchitect/forge)\n\nforge is a modular Go utility library that provides common functionality with zero external dependencies. The library follows Go best practices and offers excellent performance, comprehensive documentation, and high test coverage.\n\n## Features\n\n- **Zero Dependencies**: Only uses the Go standard library\n- **Modular Design**: Import only what you need\n- **High Performance**: Optimized for efficiency\n- **Comprehensive Testing**: High test coverage with edge case handling\n- **Excellent Documentation**: Every exported function has clear documentation and examples\n- **Type Safety**: Leverages Go generics for type-safe operations\n\n## Installation\n\n```bash\ngo get github.com/backendArchitect/forge\n```\n\n## Packages\n\n### conv - Type Conversion Utilities\n\n```go\nimport \"github.com/backendArchitect/forge/conv\"\n\n// Convert various types to integers\nage, err := conv.ToInt(\"25\")\ncount := conv.Must(conv.ToInt(\"42\")) // Using with must package\n\n// Convert anything to string\nstr := conv.ToString(123)\nstr = conv.ToString(true)\n\n// Convert to boolean with comprehensive support\nisActive, err := conv.ToBool(\"true\")  // true\nenabled := conv.ToBool(1)             // true\ndisabled := conv.ToBool(0)            // false\n\n// Convert to float64 with type safety\nprice, err := conv.ToFloat64(\"123.45\")\nratio := conv.ToFloat64(42)           // 42.0\n\n// JSON operations\ntype Person struct {\n    Name string `json:\"name\"`\n    Age  int    `json:\"age\"`\n}\n\njsonStr, _ := conv.ToJSON(Person{Name: \"John\", Age: 30})\nperson, _ := conv.FromJSON[Person](jsonStr)\n\n// Type-safe slice conversion\nnumbers, _ := conv.ToSlice[int]([]int{1, 2, 3})\n```\n\n### sliceutil - Slice Operations\n\n```go\nimport \"github.com/backendArchitect/forge/sliceutil\"\n\nnumbers := []int{1, 2, 2, 3, 1, 4}\n\n// Remove duplicates\nunique := sliceutil.Unique(numbers) // [1, 2, 3, 4]\n\n// Filter elements\nevens := sliceutil.Filter(numbers, func(x int) bool { return x%2 == 0 })\n\n// Transform elements\nstrings := sliceutil.Map(numbers, func(x int) string { \n    return fmt.Sprintf(\"num_%d\", x) \n})\n\n// Reduce to single value\nsum := sliceutil.Reduce(numbers, 0, func(acc, x int) int { return acc + x })\n\n// Split into chunks\nchunks := sliceutil.Chunk(numbers, 2) // [[1, 2], [2, 3], [1, 4]]\n\n// Check containment\nhasTwo := sliceutil.Contains(numbers, 2) // true\n\n// Shuffle elements\nshuffled := sliceutil.Shuffle(numbers)\n\n// Find differences\ndiff := sliceutil.Difference([]int{1, 2, 3}, []int{2, 4}) // [1, 3]\n\n// Find intersections\ncommon := sliceutil.Intersection([]int{1, 2, 3}, []int{2, 3, 4}) // [2, 3]\n\n// Reverse elements in place\nreversed := sliceutil.Reverse([]int{1, 2, 3, 4}) // [4, 3, 2, 1]\n```\n\n### strutil - String Utilities\n\n```go\nimport \"github.com/backendArchitect/forge/strutil\"\n\n// Generate random strings\nrandomID := strutil.Random(8) // \"aBc3DeF9\"\ncustomRandom := strutil.Random(5, \"12345\") // \"31425\"\n\n// Check if string is blank\nisEmpty := strutil.IsBlank(\"   \") // true\n\n// Truncate strings\nshort := strutil.Truncate(\"Hello World\", 5, \"...\") // \"He...\"\n\n// Case conversions\nsnake := strutil.CamelToSnake(\"myFunctionName\") // \"my_function_name\"\ncamel := strutil.SnakeToCamel(\"my_function_name\") // \"myFunctionName\"\n\n// Template substitution\ntemplate := \"Hello {{name}}, you are {{age}} years old\"\ndata := map[string]any{\"name\": \"John\", \"age\": 30}\nresult, _ := strutil.Template(template, data)\n// \"Hello John, you are 30 years old\"\n\n// Pad strings to specific length\npadded := strutil.Pad(\"hello\", 10, ' ')    // \"hello     \"\ncentered := strutil.Pad(\"hi\", 6, '*')      // \"hi****\"\n\n// Capitalize first letter\ntitle := strutil.Capitalize(\"hello WORLD\") // \"Hello world\"\n\n// Reverse string characters\nbackwards := strutil.Reverse(\"hello\")      // \"olleh\"\n```\n\n### async - Concurrency Utilities\n\n```go\nimport \"github.com/backendArchitect/forge/async\"\n\n// Parallel processing with order preservation\nnumbers := []int{1, 2, 3, 4, 5}\nsquares := async.ParallelMap(numbers, func(x int) int {\n    time.Sleep(100 * time.Millisecond) // Simulate work\n    return x * x\n})\n\n// Error group for managing goroutines\neg := \u0026async.ErrGroup{}\nfor i := 0; i \u003c 5; i++ {\n    i := i\n    eg.Go(func() error {\n        // Do work that might return an error\n        return processItem(i)\n    })\n}\nif err := eg.Wait(); err != nil {\n    log.Printf(\"Error: %v\", err)\n}\n\n// Worker pool\npool := async.NewPool(3)\ndefer pool.Close()\n\ntasks := []func(){\n    func() { fmt.Println(\"Task 1\") },\n    func() { fmt.Println(\"Task 2\") },\n    func() { fmt.Println(\"Task 3\") },\n}\npool.Submit(tasks...)\npool.Wait()\n\n// Debounce function calls\ndebouncedSave := async.Debounce(func() {\n    fmt.Println(\"Saving...\")\n}, 300*time.Millisecond)\n\n// Throttle function calls\nthrottledUpdate := async.Throttle(func() {\n    fmt.Println(\"Updating...\")\n}, 100*time.Millisecond)\n\n// Execute functions with timeout\nerr := async.Timeout(func() error {\n    // Some operation that might take too long\n    return doSomething()\n}, 5*time.Second)\n\n// Retry operations with exponential backoff\nresult, err := async.Retry(func() (string, error) {\n    return fetchDataFromAPI()\n}, 3, 100*time.Millisecond)\n```\n\n### must - Panic on Error\n\n```go\nimport \"github.com/backendArchitect/forge/must\"\n\n// Panic if error is not nil, otherwise return value\nconfig := must.Must(loadConfig()) \nport := must.Must(strconv.Atoi(os.Getenv(\"PORT\")))\n\n// Panic if error is not nil (for functions that only return error)\nfile, err := os.Open(\"config.txt\")\nmust.Must0(err)\ndefer file.Close()\n```\n\n### fsutil - File System Utilities\n\n```go\nimport \"github.com/backendArchitect/forge/fsutil\"\n\n// Check file/directory existence\nif fsutil.Exists(\"/path/to/file\") {\n    fmt.Println(\"File exists\")\n}\n\nif fsutil.IsFile(\"/path/to/file\") {\n    fmt.Println(\"It's a file\")\n}\n\nif fsutil.IsDir(\"/path/to/directory\") {\n    fmt.Println(\"It's a directory\")\n}\n\n// JSON file operations\ntype Config struct {\n    Host string `json:\"host\"`\n    Port int    `json:\"port\"`\n}\n\nconfig := Config{Host: \"localhost\", Port: 8080}\nmust.Must0(fsutil.WriteJSON(\"config.json\", config))\n\nvar loadedConfig Config\nmust.Must0(fsutil.ReadJSON(\"config.json\", \u0026loadedConfig))\n\n// Copy files\nmust.Must0(fsutil.CopyFile(\"source.txt\", \"destination.txt\"))\n\n// Ensure directory exists\nmust.Must0(fsutil.EnsureDir(\"/path/to/nested/directory\"))\n\n// Read and write text files\ncontent, err := fsutil.ReadFile(\"config.txt\")\nmust.Must0(fsutil.WriteFile(\"output.txt\", \"Hello, World!\"))\n```\n\n## Contributing\n\nContributions are welcome! Please ensure that:\n\n1. Code follows Go conventions and best practices\n2. All functions have comprehensive documentation with examples\n3. Tests cover happy paths, edge cases, and error conditions\n4. No external dependencies are introduced\n5. CI pipeline passes (linting, testing, and building)\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbackendarchitect%2Fforge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbackendarchitect%2Fforge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbackendarchitect%2Fforge/lists"}