{"id":13492768,"url":"https://github.com/oxtoacart/bpool","last_synced_at":"2025-05-15T10:01:39.185Z","repository":{"id":12828125,"uuid":"15503430","full_name":"oxtoacart/bpool","owner":"oxtoacart","description":"Buffer/Byte pool for Go","archived":false,"fork":false,"pushed_at":"2019-05-30T20:26:42.000Z","size":16,"stargazers_count":475,"open_issues_count":4,"forks_count":52,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-04-15T01:59:19.394Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oxtoacart.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}},"created_at":"2013-12-29T04:18:01.000Z","updated_at":"2025-04-13T04:35:40.000Z","dependencies_parsed_at":"2022-08-26T22:25:45.682Z","dependency_job_id":null,"html_url":"https://github.com/oxtoacart/bpool","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/oxtoacart%2Fbpool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxtoacart%2Fbpool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxtoacart%2Fbpool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxtoacart%2Fbpool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oxtoacart","download_url":"https://codeload.github.com/oxtoacart/bpool/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254319715,"owners_count":22051072,"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-07-31T19:01:08.969Z","updated_at":"2025-05-15T10:01:38.700Z","avatar_url":"https://github.com/oxtoacart.png","language":"Go","funding_links":[],"categories":["开源类库","Go","Open source library"],"sub_categories":["开发辅助包","Development Aid Package"],"readme":"# bpool [![GoDoc](https://godoc.org/github.com/oxtoacart/bpool?status.png)](https://godoc.org/github.com/oxtoacart/bpool)\n\nPackage bpool implements leaky pools of byte arrays and Buffers as bounded channels. \nIt is based on the leaky buffer example from the Effective Go documentation: http://golang.org/doc/effective_go.html#leaky_buffer\n\nbpool provides the following pool types:\n\n* [bpool.BufferPool](https://godoc.org/github.com/oxtoacart/bpool#BufferPool)\n  which provides a fixed-size pool of\n  [bytes.Buffers](http://golang.org/pkg/bytes/#Buffer).\n* [bpool.BytePool](https://godoc.org/github.com/oxtoacart/bpool#BytePool) which\n  provides a fixed-size pool of `[]byte` slices with a pre-set width (length).\n* [bpool.SizedBufferPool](https://godoc.org/github.com/oxtoacart/bpool#SizedBufferPool), \n  which is an alternative to `bpool.BufferPool` that pre-sizes the capacity of\n  buffers issued from the pool and discards buffers that have grown too large\n  upon return.\n\nA common use case for this package is to use buffers to execute HTML templates\nagainst (via ExecuteTemplate) or encode JSON into (via json.NewEncoder). This\nallows you to catch any rendering or marshalling errors prior to writing to a\n`http.ResponseWriter`, which helps to avoid writing incomplete or malformed data\nto the response.\n\n## Install\n\n`go get github.com/oxtoacart/bpool`\n\n## Documentation\n\nSee [godoc.org](http://godoc.org/github.com/oxtoacart/bpool) or use `godoc github.com/oxtoacart/bpool`\n\n## Example\n\nHere's a quick example for using `bpool.BufferPool`. We create a pool of the\ndesired size, call the `Get()` method to obtain a buffer for use, and call\n`Put(buf)` to return the buffer to the pool.\n\n```go\n\nvar bufpool *bpool.BufferPool\n\nfunc main() {\n\n    bufpool = bpool.NewBufferPool(48)\n\n}\n\nfunc someFunction() error {\n\n     // Get a buffer from the pool\n     buf := bufpool.Get()\n     ...\n     ...\n     ...\n     // Return the buffer to the pool\n     bufpool.Put(buf)\n\n     return nil\n}\n```\n\n## License\n\nApache 2.0 Licensed. See the LICENSE file for details.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foxtoacart%2Fbpool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foxtoacart%2Fbpool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foxtoacart%2Fbpool/lists"}