{"id":22654232,"url":"https://github.com/stevencyb/gotokenizer","last_synced_at":"2025-08-06T08:32:09.450Z","repository":{"id":232378630,"uuid":"784148477","full_name":"StevenCyb/gotokenizer","owner":"StevenCyb","description":"A golang helper that provides a regex based tokenizer.","archived":false,"fork":false,"pushed_at":"2024-04-09T11:32:49.000Z","size":20,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-06-20T14:09:08.521Z","etag":null,"topics":[],"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/StevenCyb.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":"2024-04-09T09:27:35.000Z","updated_at":"2024-04-09T11:16:25.000Z","dependencies_parsed_at":"2024-04-09T15:01:27.846Z","dependency_job_id":"381dcbc4-d1eb-453d-8b2d-4de73b0f551c","html_url":"https://github.com/StevenCyb/gotokenizer","commit_stats":null,"previous_names":["stevencyb/gotokenizer"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StevenCyb%2Fgotokenizer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StevenCyb%2Fgotokenizer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StevenCyb%2Fgotokenizer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StevenCyb%2Fgotokenizer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StevenCyb","download_url":"https://codeload.github.com/StevenCyb/gotokenizer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228867094,"owners_count":17983874,"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-12-09T09:35:57.780Z","updated_at":"2024-12-09T09:35:58.286Z","avatar_url":"https://github.com/StevenCyb.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gotokenizer\n\n[![GitHub release badge](https://badgen.net/github/release/StevenCyb/gotokenizer/latest?label=Latest\u0026logo=GitHub)](https://github.com/StevenCyb/gotokenizer/releases/latest)\n![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/StevenCyb/gotokenizer/ci-test.yml?label=Tests\u0026logo=GitHub)\n![GitHub](https://img.shields.io/github/license/StevenCyb/gotokenizer)\n\nThis library provide a basic regex based tokenizer.\n\n## Installation\n\nTo install the library, you can use the following command:\n\n```sh\ngo get github.com/StevenCyb/gotokenizer\n```\n\n## How to use\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n  // Import the package\n\t\"gotokenizer/pkg/tokenizer\"\n)\n\nfunc main() {\n  // Define token types that you want to classify.\n\tvar (\n\t\tWordType      tokenizer.Type = \"WORD\"\n\t\tSeparatorType tokenizer.Type = \"SEPARATOR\"\n\t\tSkipType      tokenizer.Type = \"SKIP\"\n\t)\n\n  input := \"hello,world\"\n\n  // Create a tokenizer\n\ttokenizer := tokenizer.New(\n    // Input to parse\n\t\tinput,\n    // Token that should be skipped e.g. spaces.\n\t\tSkipType,\n    // Specs for token types and how to identify them.\n\t\t[]*tokenizer.Spec{\n\t\t\ttokenizer.NewSpec(`^\\s+`, SkipType),\n\t\t\ttokenizer.NewSpec(\"^[a-z]+\", WordType),\n\t\t\ttokenizer.NewSpec(\"^,\", SeparatorType),\n\t\t})\n\n\tfor {\n    // Get next token\n\t\ttoken, err := tokenizer.GetNextToken()\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t} else if token == nil {\n      // At the end\n\t\t\tbreak\n\t\t}\n\n    // Print result (see image below)\n\t\tfmt.Printf(\"\\x1B[32m%s\\033[0m -\u003e \\x1B[31m%s\\033[0m\\n\", token.Type, token.Value)\n\t}\n}\n```\n\u003cimg src=\".media/log_output.png\" width=\"250\"\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstevencyb%2Fgotokenizer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstevencyb%2Fgotokenizer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstevencyb%2Fgotokenizer/lists"}