{"id":16931895,"url":"https://github.com/leodido/go-urn","last_synced_at":"2025-04-12T21:33:49.593Z","repository":{"id":37502493,"uuid":"111491216","full_name":"leodido/go-urn","owner":"leodido","description":"Parser for uniform resource names as seen on RFC 8141, RFC 2141, and RFC 7643","archived":false,"fork":false,"pushed_at":"2024-02-03T11:10:30.000Z","size":5085,"stargazers_count":91,"open_issues_count":5,"forks_count":11,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-11T09:18:25.190Z","etag":null,"topics":["go","hacktoberfest","parser","ragel","rfc-2141","rfc-7643","rfc-8141","urn"],"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/leodido.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}},"created_at":"2017-11-21T02:58:47.000Z","updated_at":"2025-04-08T16:58:16.000Z","dependencies_parsed_at":"2024-02-03T12:35:24.974Z","dependency_job_id":null,"html_url":"https://github.com/leodido/go-urn","commit_stats":{"total_commits":101,"total_committers":4,"mean_commits":25.25,"dds":0.02970297029702973,"last_synced_commit":"e3ef3a8d8111b9629cd6381915ca23210e4ea7c5"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leodido%2Fgo-urn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leodido%2Fgo-urn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leodido%2Fgo-urn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leodido%2Fgo-urn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leodido","download_url":"https://codeload.github.com/leodido/go-urn/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248636207,"owners_count":21137398,"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":["go","hacktoberfest","parser","ragel","rfc-2141","rfc-7643","rfc-8141","urn"],"created_at":"2024-10-13T20:44:57.256Z","updated_at":"2025-04-12T21:33:49.568Z","avatar_url":"https://github.com/leodido.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build](https://img.shields.io/circleci/build/github/leodido/go-urn?style=for-the-badge)](https://app.circleci.com/pipelines/github/leodido/go-urn) [![Coverage](https://img.shields.io/codecov/c/github/leodido/go-urn.svg?style=for-the-badge)](https://codecov.io/gh/leodido/go-urn) [![Documentation](https://img.shields.io/badge/godoc-reference-blue.svg?style=for-the-badge)](https://godoc.org/github.com/leodido/go-urn)\n\n**A parser for URNs**.\n\n\u003e As seen on [RFC 2141](https://datatracker.ietf.org/doc/html/rfc2141), [RFC 7643](https://datatracker.ietf.org/doc/html/rfc7643#section-10), and on [RFC 8141](https://datatracker.ietf.org/doc/html/rfc8141).\n\n[API documentation](https://godoc.org/github.com/leodido/go-urn).\n\nStarting with version 1.3 this library also supports [RFC 7643 SCIM URNs](https://datatracker.ietf.org/doc/html/rfc7643#section-10).\n\nStarting with version 1.4 this library also supports [RFC 8141 URNs (2017)](https://datatracker.ietf.org/doc/html/rfc8141).\n\n## Installation\n\n```\ngo get github.com/leodido/go-urn\n```\n\n## Features\n\n1. RFC 2141 URNs parsing (default)\n2. RFC 8141 URNs parsing (supersedes RFC 2141)\n3. RFC 7643 SCIM URNs parsing\n4. Normalization as per RFCs\n5. Lexical equivalence as per RFCs\n6. Precise, fine-grained errors\n\n## Performances\n\nThis implementation results to be really fast.\n\nUsually below 400 ns on my machine\u003csup\u003e[1](#mymachine)\u003c/sup\u003e.\n\nNotice it also performs, while parsing:\n\n1. fine-grained and informative erroring\n2. specific-string normalization\n\n```\nok/00/urn:a:b______________________________________/-10    51372006    109.0 ns/op    275 B/op    3 allocs/op\nok/01/URN:foo:a123,456_____________________________/-10    36024072    160.8 ns/op    296 B/op    6 allocs/op\nok/02/urn:foo:a123%2C456___________________________/-10    31901007    188.4 ns/op    320 B/op    7 allocs/op\nok/03/urn:ietf:params:scim:schemas:core:2.0:User___/-10    22736756    266.6 ns/op    376 B/op    6 allocs/op\nok/04/urn:ietf:params:scim:schemas:extension:enterp/-10    18291859    335.2 ns/op    408 B/op    6 allocs/op\nok/05/urn:ietf:params:scim:schemas:extension:enterp/-10    15283087    379.4 ns/op    440 B/op    6 allocs/op\nok/06/urn:burnout:nss______________________________/-10    39407593    155.1 ns/op    288 B/op    6 allocs/op\nok/07/urn:abcdefghilmnopqrstuvzabcdefghilm:x_______/-10    27832718    211.4 ns/op    307 B/op    4 allocs/op\nok/08/urn:urnurnurn:urn____________________________/-10    33269596    168.1 ns/op    293 B/op    6 allocs/op\nok/09/urn:ciao:!!*_________________________________/-10    41100675    148.8 ns/op    288 B/op    6 allocs/op\nok/10/urn:ciao:=@__________________________________/-10    37214253    149.7 ns/op    284 B/op    6 allocs/op\nok/11/urn:ciao:@!=%2C(xyz)+a,b.*@g=$_'_____________/-10    26534240    229.8 ns/op    336 B/op    7 allocs/op\nok/12/URN:x:abc%1Dz%2F%3az_________________________/-10    28166396    211.8 ns/op    336 B/op    7 allocs/op\nno/13/URN:---xxx:x_________________________________/-10    23635159    255.6 ns/op    419 B/op    5 allocs/op\nno/14/urn::colon:nss_______________________________/-10    23594779    258.4 ns/op    419 B/op    5 allocs/op\nno/15/URN:@,:x_____________________________________/-10    23742535    261.5 ns/op    419 B/op    5 allocs/op\nno/16/URN:URN:NSS__________________________________/-10    27432714    223.3 ns/op    371 B/op    5 allocs/op\nno/17/urn:UrN:NSS__________________________________/-10    26922117    224.9 ns/op    371 B/op    5 allocs/op\nno/18/urn:a:%______________________________________/-10    24926733    224.6 ns/op    371 B/op    5 allocs/op\nno/19/urn:urn:NSS__________________________________/-10    27652641    220.7 ns/op    371 B/op    5 allocs/op\n```\n\n* \u003ca name=\"mymachine\"\u003e[1]\u003c/a\u003e: Apple M1 Pro\n\n\n## Example\n\nFor more examples take a look at the [examples file](examples_test.go).\n\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/leodido/go-urn\"\n)\n\nfunc main() {\n\tvar uid = \"URN:foo:a123,456\"\n\n    // Parse the input string as a RFC 2141 URN only\n\tu, e := urn.NewMachine().Parse(uid)\n\tif e != nil {\n\t\tfmt.Errorf(err)\n\n\t\treturn\n\t}\n\n\tfmt.Println(u.ID)\n\tfmt.Println(u.SS)\n\n\t// Output:\n\t// foo\n\t// a123,456\n}\n```\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/leodido/go-urn\"\n)\n\nfunc main() {\n\tvar uid = \"URN:foo:a123,456\"\n\n    // Parse the input string as a RFC 2141 URN only\n\tu, ok := urn.Parse([]byte(uid))\n\tif !ok {\n\t\tpanic(\"error parsing urn\")\n\t}\n\n\tfmt.Println(u.ID)\n\tfmt.Println(u.SS)\n\n\t// Output:\n\t// foo\n\t// a123,456\n}\n```\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/leodido/go-urn\"\n)\n\nfunc main() {\n\tinput := \"urn:ietf:params:scim:api:messages:2.0:ListResponse\"\n\n\t// Parsing the input string as a RFC 7643 SCIM URN\n\tu, ok := urn.Parse([]byte(input), urn.WithParsingMode(urn.RFC7643Only))\n\tif !ok {\n\t\tpanic(\"error parsing urn\")\n\t}\n\n\tfmt.Println(u.IsSCIM())\n\tscim := u.SCIM()\n\tfmt.Println(scim.Type.String())\n\tfmt.Println(scim.Name)\n\tfmt.Println(scim.Other)\n\n\t// Output:\n\t// true\n\t// api\n\t// messages\n\t// 2.0:ListResponse\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleodido%2Fgo-urn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleodido%2Fgo-urn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleodido%2Fgo-urn/lists"}