{"id":13694592,"url":"https://github.com/ipfs/go-cid","last_synced_at":"2025-04-11T16:22:40.343Z","repository":{"id":40719357,"uuid":"66386779","full_name":"ipfs/go-cid","owner":"ipfs","description":"Content ID v1 implemented in go","archived":false,"fork":false,"pushed_at":"2025-03-24T09:20:03.000Z","size":253,"stargazers_count":159,"open_issues_count":7,"forks_count":47,"subscribers_count":28,"default_branch":"master","last_synced_at":"2025-03-28T10:00:28.367Z","etag":null,"topics":["cid","ipld","multiformats"],"latest_commit_sha":null,"homepage":"","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/ipfs.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":"2016-08-23T17:05:22.000Z","updated_at":"2025-02-16T21:33:20.000Z","dependencies_parsed_at":"2024-03-14T12:43:27.994Z","dependency_job_id":"53fd9bdb-3dd4-45c3-b714-63381ebdb54a","html_url":"https://github.com/ipfs/go-cid","commit_stats":{"total_commits":267,"total_committers":38,"mean_commits":7.026315789473684,"dds":0.8389513108614233,"last_synced_commit":"7f61b44eb93ea36191d53fa7f469281aa028fd55"},"previous_names":[],"tags_count":49,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipfs%2Fgo-cid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipfs%2Fgo-cid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipfs%2Fgo-cid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipfs%2Fgo-cid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ipfs","download_url":"https://codeload.github.com/ipfs/go-cid/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247157276,"owners_count":20893220,"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":["cid","ipld","multiformats"],"created_at":"2024-08-02T17:01:35.312Z","updated_at":"2025-04-04T11:06:28.385Z","avatar_url":"https://github.com/ipfs.png","language":"Go","funding_links":[],"categories":["开源类库","Go","Open source library"],"sub_categories":["未归类","Not Categorized"],"readme":"go-cid\n==================\n\n[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io)\n[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/)\n[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)\n[![](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)\n[![GoDoc](https://godoc.org/github.com/ipfs/go-cid?status.svg)](https://godoc.org/github.com/ipfs/go-cid)\n[![Coverage Status](https://coveralls.io/repos/github/ipfs/go-cid/badge.svg?branch=master)](https://coveralls.io/github/ipfs/go-cid?branch=master)\n[![Travis CI](https://travis-ci.org/ipfs/go-cid.svg?branch=master)](https://travis-ci.org/ipfs/go-cid)\n\n\u003e A package to handle content IDs in Go.\n\nThis is an implementation in Go of the [CID spec](https://github.com/ipld/cid).\nIt is used in `go-ipfs` and related packages to refer to a typed hunk of data.\n\n## Lead Maintainer\n\n[Eric Myhre](https://github.com/warpfork)\n\n## Table of Contents\n\n- [Install](#install)\n- [Usage](#usage)\n- [API](#api)\n- [Contribute](#contribute)\n- [License](#license)\n\n## Install\n\n`go-cid` is a standard Go module which can be installed with:\n\n```sh\ngo get github.com/ipfs/go-cid\n```\n\n## Usage\n\n### Running tests\n\nRun tests with `go test` from the directory root\n\n```sh\ngo test\n```\n\n### Examples\n\n#### Parsing string input from users\n\n```go\n// Create a cid from a marshaled string\nc, err := cid.Decode(\"bafzbeigai3eoy2ccc7ybwjfz5r3rdxqrinwi4rwytly24tdbh6yk7zslrm\")\nif err != nil {...}\n\nfmt.Println(\"Got CID: \", c)\n```\n\n#### Creating a CID from scratch\n\n```go\n\nimport (\n  cid \"github.com/ipfs/go-cid\"\n  mc \"github.com/multiformats/go-multicodec\"\n  mh \"github.com/multiformats/go-multihash\"\n)\n\n// Create a cid manually by specifying the 'prefix' parameters\npref := cid.Prefix{\n\tVersion: 1,\n\tCodec: uint64(mc.Raw),\n\tMhType: mh.SHA2_256,\n\tMhLength: -1, // default length\n}\n\n// And then feed it some data\nc, err := pref.Sum([]byte(\"Hello World!\"))\nif err != nil {...}\n\nfmt.Println(\"Created CID: \", c)\n```\n\n#### Check if two CIDs match\n\n```go\n// To test if two cid's are equivalent, be sure to use the 'Equals' method:\nif c1.Equals(c2) {\n\tfmt.Println(\"These two refer to the same exact data!\")\n}\n```\n\n#### Check if some data matches a given CID\n\n```go\n// To check if some data matches a given cid, \n// Get your CIDs prefix, and use that to sum the data in question:\nother, err := c.Prefix().Sum(mydata)\nif err != nil {...}\n\nif !c.Equals(other) {\n\tfmt.Println(\"This data is different.\")\n}\n\n```\n\n## Contribute\n\nPRs are welcome!\n\nSmall note: If editing the Readme, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification.\n\n## License\n\nMIT © Jeromy Johnson\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fipfs%2Fgo-cid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fipfs%2Fgo-cid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fipfs%2Fgo-cid/lists"}