{"id":13563152,"url":"https://github.com/elliotchance/pie","last_synced_at":"2025-05-12T13:19:38.277Z","repository":{"id":34419260,"uuid":"178954418","full_name":"elliotchance/pie","owner":"elliotchance","description":"🍕 Enjoy a slice! A utility library for dealing with slices and maps that focuses on type safety and performance.","archived":false,"fork":false,"pushed_at":"2024-11-26T03:07:17.000Z","size":856,"stargazers_count":1999,"open_issues_count":23,"forks_count":96,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-05-12T13:19:28.744Z","etag":null,"topics":["generics","go","golang","slices","utility"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/elliotchance/pie/v2","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/elliotchance.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":"2019-04-01T22:08:04.000Z","updated_at":"2025-04-29T08:47:11.000Z","dependencies_parsed_at":"2023-01-15T06:59:16.070Z","dependency_job_id":"e08386dd-e306-4c2c-8c44-58f843985613","html_url":"https://github.com/elliotchance/pie","commit_stats":{"total_commits":110,"total_committers":31,"mean_commits":"3.5483870967741935","dds":0.5454545454545454,"last_synced_commit":"d8f7169efe5b614a8df34595af5d2e816157c76a"},"previous_names":[],"tags_count":80,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elliotchance%2Fpie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elliotchance%2Fpie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elliotchance%2Fpie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elliotchance%2Fpie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elliotchance","download_url":"https://codeload.github.com/elliotchance/pie/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253745196,"owners_count":21957319,"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":["generics","go","golang","slices","utility"],"created_at":"2024-08-01T13:01:15.672Z","updated_at":"2025-05-12T13:19:38.254Z","avatar_url":"https://github.com/elliotchance.png","language":"Go","funding_links":[],"categories":["开源类库","Go","Uncategorized","Programming","Repositories"],"sub_categories":["开发辅助包","Uncategorized","Go"],"readme":"# 🍕 `github.com/elliotchance/pie`\n[![GoDoc](https://godoc.org/github.com/elliotchance/pie?status.svg)](https://godoc.org/github.com/elliotchance/pie)\n[![Build Status](https://travis-ci.org/elliotchance/pie.svg?branch=master)](https://travis-ci.org/elliotchance/pie)\n[![codecov](https://codecov.io/gh/elliotchance/pie/branch/master/graph/badge.svg)](https://codecov.io/gh/elliotchance/pie)\n\n**Enjoy a slice!** `pie` is a library of utility functions for common operations\non slices and maps.\n\n- [Quick Start](#quick-start)\n- [FAQ](#faq)\n  * [What are the requirements?](#what-are-the-requirements)\n  * [What are the goals of `pie`?](#what-are-the-goals-of-pie)\n  * [How do I contribute a function?](#how-do-i-contribute-a-function)\n  * [Why is the emoji a slice of pizza instead of a pie?](#why-is-the-emoji-a-slice-of-pizza-instead-of-a-pie)\n\n# Quick Start\n\nIf you are using (or require) Go 1.17 or below, you will have to\n[use v1](https://github.com/elliotchance/pie/v1).\n\n`pie` can be used in two ways, the first is to use the regular\n[parameterized functions](https://go.googlesource.com/proposal/+/master/design/15292/2013-12-type-params.md):\n\n[Run this program](https://go.dev/play/p/qYaBXPRs3Nk)\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"strings\"\n\n    \"github.com/elliotchance/pie/v2\"\n)\n\nfunc main() {\n    names := pie.FilterNot([]string{\"Bob\", \"Sally\", \"John\", \"Jane\"},\n        func(name string) bool {\n            return strings.HasPrefix(name, \"J\")\n        })\n\n    fmt.Println(names) // \"[Bob Sally]\"\n}\n```\n\nOr, if you need to chain multiple operations you can use one of:\n\n- [`pie.Of`](https://pkg.go.dev/github.com/elliotchance/pie/v2#Of) - works with any element type, but functions are limited.\n- [`pie.OfOrdered`](https://pkg.go.dev/github.com/elliotchance/pie/v2#OfOrdered) - only works with numbers and strings, but has more functions.\n- [`pie.OfNumeric`](https://pkg.go.dev/github.com/elliotchance/pie/v2#OfNumeric) - only works with numbers, but has all functions.\n\n[Run this program](https://go.dev/play/p/4IhVbw0koxg)\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"strings\"\n\n    \"github.com/elliotchance/pie/v2\"\n)\n\nfunc main() {\n    name := pie.Of([]string{\"Bob\", \"Sally\", \"John\", \"Jane\"}).\n        FilterNot(func(name string) bool {\n            return strings.HasPrefix(name, \"J\")\n        }).\n        Map(strings.ToUpper).\n        Last()\n\n    fmt.Println(name) // \"SALLY\"\n}\n```\n\nYou can find the\n[full documentation here](https://pkg.go.dev/github.com/elliotchance/pie/v2).\n\n# FAQ\n\n## What are the requirements?\n\n`pie` v2 only supports Go 1.18+. If you have an older version you can\n[use v1](https://github.com/elliotchance/pie/v1).\n\n## What are the goals of `pie`?\n\n1. **Type safety.** I never want to hit runtime bugs because I could pass in the\nwrong type, or perform an invalid type case out the other end.\n\n2. **Performance.** The functions need to be as fast as native Go\nimplementations otherwise there's no point in this library existing.\n\n3. **Nil-safe.** All of the functions will happily accept nil and treat them as\nempty slices. Apart from less possible panics, it makes it easier to chain.\n\n4. **Immutable.** Functions never modify inputs (except in cases where it would\nbe illogical), unlike some built-ins such as `sort.Strings`.\n\n## How do I contribute a function?\n\nPull requests are always welcome.\n\nHere is a comprehensive list of steps to follow to add a new function:\n\n1. Create a new file for your function (tip: copy an existing file can be\nquicker). Add your implmentation and comment.\n\n2. Create appropriate tests.\n\n3. If your function accepts a slice, it should also be added to the `OfSlice`\nAPI (see `of.go`).\n\n## Why is the emoji a slice of pizza instead of a pie?\n\nI wanted to pick a name for the project that was short and had an associated\nemoji. I liked pie, but then I found out that the pie emoji is not fully\nsupported everywhere. I didn't want to change the name of the project to cake,\nbut pizza pie still made sense. I'm not sure if I will change it back to a pie\nlater.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felliotchance%2Fpie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felliotchance%2Fpie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felliotchance%2Fpie/lists"}