{"id":18779325,"url":"https://github.com/zostay/go-std","last_synced_at":"2025-04-13T10:33:53.529Z","repository":{"id":152129652,"uuid":"625040437","full_name":"zostay/go-std","owner":"zostay","description":"The missing std library components for golang","archived":false,"fork":false,"pushed_at":"2024-12-04T22:08:57.000Z","size":120,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T02:43:15.362Z","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/zostay.png","metadata":{"files":{"readme":"README.md","changelog":"Changes.md","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":"2023-04-07T22:47:19.000Z","updated_at":"2024-12-10T18:20:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"da8606fd-af54-49d3-80a1-96a34a14073e","html_url":"https://github.com/zostay/go-std","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zostay%2Fgo-std","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zostay%2Fgo-std/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zostay%2Fgo-std/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zostay%2Fgo-std/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zostay","download_url":"https://codeload.github.com/zostay/go-std/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248699441,"owners_count":21147644,"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-07T20:19:37.970Z","updated_at":"2025-04-13T10:33:53.516Z","avatar_url":"https://github.com/zostay.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Zostays Go-Std\n\nThere are a lot of common operations simply missing from the Golang builtin\nlibrary. This makes up for that deficiency. Here's a summary of some of the\nprovided tools:\n\n## Byte Slice Operations\n\nHere's a few additional operations for working with slices of bytes:\n\n* `ContainsOnly(b, chars)`\n* `TrimToOnly(b, chars)`\n* `FromRange(a, z)`\n* `Reverse(b)`\n* `Indent(b, indent)`\n\n## Deferred Handling\n\nHandling deferred functions is a bit of a pain. This provides a way to handle\ncertain deferred calls with a little less hassle:\n\n* `Error` (allows capturing both errors that may occur during defer)\n\n## FileSystem Operations\n\nThe built-in `io/fs` package is fine for reading files, but is missing write interfaces. This provides them:\n\n* `FileWriter` (analogous to `fs.File`, but for writes)\n* `CreateFS`\n* `WriteFileFS`\n\nAnd then provides some additional general interfaces:\n\n* `ReaderFS`\n* `ReaderWriterFS`\n* `WriterFS`\n\nAnd provides some convenience functions for working with them:\n\n* `MkdirAll(fsys, name, perm)`\n* `WriteFile(fsys, name, data, perm)`\n\n## Generic/Interface Comparison\n\nThe built-in comparable generic is pretty weak. Just good enough for map key\ntypes, but not much else. We provide a compare.Able interface which covers all\nthe types that can be compared using `\u003c`, `\u003e`, `\u003c=`, and `\u003e=` operators, in\naddition to `==` and `!=`. Then we provide the following operations on them:\n\n * `CountDeltas(a, b, delta)`\n * `Max(a, b)`\n * `Min(a, b)`\n * `Less(a, b)`\n * `Zero()`\n * `FirstNonZero(...vals)`\n * `FirstNonNil(...vals)`\n\nThen we create a generic interface for doing the same thing generally, which\nlooks similar to what the built-in `sort` package does but then implements the\nfunctions to make such an interface even more useful:\n\n * `MaxI(a, b)`\n * `MinI(a, b)`\n * `LessI(a, b)`\n\n## Generic Iteration\n\nIteration in Golang is provided by using a `for`-loop with the `range` keyword.\nThis has some deficiencies, however. This iterator cannot be passed around\nin-progress. Also, when iterating over maps, the iterator is over key/value\npairs rather than index/value pairs. Sometimes it's also helpful to have that\nindex.\n\n## Generic List Operations for Slices\n\nMany common slice operations are a bit tedious to implement. It's easy to get\noff-by-one errors, so the following ops are provided:\n\n * `FromRange(a, z, delta)`\n * `Delete(slice, index)`\n * `DeleteValue(slice, value)`\n * `DeleteAllValues(slice, value)`\n * `Insert(slice, index, value)`\n * `Push(slice, value)`\n * `Pop(slice)`\n * `Shift(slice)`\n * `Unshift(slice, value)`\n * `Concat(slice...)`\n * `Map(slice, mapper)`\n * `MapSlice(slice, mapper)`\n * `MapMap(slice, mapper)`\n * `Reduce(slice, reducer)`\n * `Reductions(slice, reducer)`\n * `ReduceAcc(slice, start, reducer)`\n * `ReductionsAcc(slice, start, reducer)`\n * `Sum(slice)`\n * `Product(slice)`\n * `Grep(slice, predicate)`\n * `GrepIndex(slice, predicate)`\n * `Any(slice, predicate)`\n * `All(slice, predicate)`\n * `None(slice, predicate)`\n * `NotAll(slice, predicate)`\n * `First(slice, predicate)`\n * `FirstIndex(slice, predicate)`\n * `FirstOr(slice, missed, predicate)`\n * `Head(slice, n)`\n * `Tail(slice, n)`\n * `Shuffle(slice)`\n * `Sample(slice, n)`\n * `Uniq(slice)`\n * `UniqInPlace(slice)`\n\n## Generic Map Transformations\n\nFrequently, you need to get just the keys or values off of a slice. This\nprovides those operations among others for maps:\n\n * `Copy(dst, src)`\n * `CopyInit(dst, src)`\n * `Keys(map)`\n * `Values(map)`\n * `KVs(map)`\n\n## Generic Map Operations\n\nThere are a lot of common map operations that are missing from the built-in\nstandard library:\n\n * `Merge(...maps)`\n * `MergeInPlace(base, ...maps)`\n * `Diff(a, b)`\n\n## Generic Sets\n\nThere's no built-in set operation. This library provides one. It provides the\nfollowing methods on sets:\n\n * `Contains(val)`\n * `Insert(val)`\n * `Delete(val)`\n * `Len()`\n * `SubsetOf(set)`\n * `Keys()`\n\nAnd then it also provides these functions to work on sets:\n\n * `Intersects(a, b)`\n * `Intersection(b, b)`\n * `Union(a, b)`\n * `Difference(a, b)`\n * `Copy(dst, src)`\n * `CopyInit(dst, src)`\n * `Diff(a, b)`\n\n## String Operations\n\nSome additional string operations are provided that are missing from the\nbuilt-in `strings` package:\n\n * `ContainsOnly(s, chars)`\n * `FromRange(a, z)`\n * `Reverse(s)`\n * `Increment(s)`\n * `IncrementWithSets(s, sets)`\n * `Indent(s, indent)`\n\nThe latter two operations might warrant their own library, but I put them here for now.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzostay%2Fgo-std","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzostay%2Fgo-std","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzostay%2Fgo-std/lists"}