{"id":35672378,"url":"https://github.com/bborbe/parse","last_synced_at":"2026-01-05T19:04:00.657Z","repository":{"id":226202557,"uuid":"768023812","full_name":"bborbe/parse","owner":"bborbe","description":null,"archived":false,"fork":false,"pushed_at":"2025-12-05T22:37:11.000Z","size":6884,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-09T12:34:17.321Z","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":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bborbe.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-03-06T10:28:53.000Z","updated_at":"2025-12-05T22:37:15.000Z","dependencies_parsed_at":"2024-03-06T12:25:48.116Z","dependency_job_id":"eaa6b131-6436-439c-8519-3e2c963dc760","html_url":"https://github.com/bborbe/parse","commit_stats":null,"previous_names":["bborbe/parse"],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/bborbe/parse","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bborbe%2Fparse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bborbe%2Fparse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bborbe%2Fparse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bborbe%2Fparse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bborbe","download_url":"https://codeload.github.com/bborbe/parse/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bborbe%2Fparse/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28218052,"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","status":"online","status_checked_at":"2026-01-05T02:00:06.358Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2026-01-05T19:02:16.620Z","updated_at":"2026-01-05T19:04:00.653Z","avatar_url":"https://github.com/bborbe.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Parse\n\n[![CI](https://github.com/bborbe/parse/workflows/CI/badge.svg)](https://github.com/bborbe/parse/actions?query=workflow%3ACI)\n[![Go Report Card](https://goreportcard.com/badge/github.com/bborbe/parse)](https://goreportcard.com/report/github.com/bborbe/parse)\n[![Go Reference](https://pkg.go.dev/badge/github.com/bborbe/parse.svg)](https://pkg.go.dev/github.com/bborbe/parse)\n[![Coverage Status](https://coveralls.io/repos/github/bborbe/parse/badge.svg?branch=master)](https://coveralls.io/github/bborbe/parse?branch=master)\n\nA robust Go utility library for parsing and converting various data types from `interface{}` values with comprehensive fallback mechanisms and error handling.\n\n## Features\n\n- **Type-safe parsing** with context support\n- **Fallback values** via `ParseXDefault` functions\n- **Subtype handling** for custom types derived from basic types\n- **Interface support** for `fmt.Stringer` implementations\n- **Comprehensive error handling** with structured errors\n- **Zero dependencies** for runtime (only `github.com/bborbe/errors`)\n\n## Installation\n\n```bash\ngo get github.com/bborbe/parse\n```\n\n## Usage\n\n### Basic String Parsing\n\n```go\nimport (\n    \"context\"\n    \"github.com/bborbe/parse\"\n)\n\n// Parse with error handling\nvalue, err := parse.ParseString(context.Background(), 42)\nif err != nil {\n    // Handle error\n}\nfmt.Println(value) // \"42\"\n\n// Parse with default fallback\nvalue := parse.ParseStringDefault(context.Background(), invalidValue, \"default\")\nfmt.Println(value) // \"default\"\n```\n\n### Integer Parsing\n\n```go\n// Parse int\nnum, err := parse.ParseInt(context.Background(), \"123\")\nif err != nil {\n    // Handle error\n}\nfmt.Println(num) // 123\n\n// Parse int64 with default\nnum64 := parse.ParseInt64Default(context.Background(), \"invalid\", 0)\nfmt.Println(num64) // 0\n```\n\n### Boolean Parsing\n\n```go\n// Parse bool\nflag, err := parse.ParseBool(context.Background(), \"true\")\nif err != nil {\n    // Handle error\n}\nfmt.Println(flag) // true\n\n// Parse with default\nflag := parse.ParseBoolDefault(context.Background(), \"invalid\", false)\nfmt.Println(flag) // false\n```\n\n### Float Parsing\n\n```go\n// Parse float64\nf, err := parse.ParseFloat64(context.Background(), \"3.14\")\nif err != nil {\n    // Handle error\n}\nfmt.Println(f) // 3.14\n```\n\n### Array Parsing\n\n```go\n// Parse string array\nstrs, err := parse.ParseStrings(context.Background(), []interface{}{\"a\", \"b\", \"c\"})\nif err != nil {\n    // Handle error\n}\nfmt.Println(strs) // [\"a\", \"b\", \"c\"]\n\n// Parse int array with default\nints := parse.ParseIntArrayDefault(context.Background(), \"invalid\", []int{1, 2, 3})\nfmt.Println(ints) // [1, 2, 3]\n```\n\n### Time Parsing\n\n```go\n// Parse time with custom format\nt, err := parse.ParseTime(context.Background(), \"2023-12-25\", \"2006-01-02\")\nif err != nil {\n    // Handle error\n}\nfmt.Println(t) // 2023-12-25 00:00:00 +0000 UTC\n```\n\n### ASCII Conversion\n\n```go\n// Convert to ASCII (removes diacritics)\nascii, err := parse.ParseASCII(context.Background(), \"café\")\nif err != nil {\n    // Handle error\n}\nfmt.Println(ascii) // \"cafe\"\n```\n\n### Custom Types\n\nThe library supports custom types derived from basic types:\n\n```go\ntype MyString string\n\nvalue, err := parse.ParseString(context.Background(), MyString(\"hello\"))\n// Works seamlessly with custom types\n```\n\n## API Reference\n\n### Core Functions\n\n- `ParseString(ctx, value) (string, error)` - Parse to string\n- `ParseInt(ctx, value) (int, error)` - Parse to int\n- `ParseInt64(ctx, value) (int64, error)` - Parse to int64\n- `ParseBool(ctx, value) (bool, error)` - Parse to bool\n- `ParseFloat64(ctx, value) (float64, error)` - Parse to float64\n- `ParseTime(ctx, value, format) (time.Time, error)` - Parse to time.Time\n- `ParseASCII(ctx, value) (string, error)` - Convert to ASCII\n\n### Array Functions\n\n- `ParseStrings(ctx, value) ([]string, error)` - Parse to string array\n- `ParseIntArray(ctx, value) ([]int, error)` - Parse to int array\n- `ParseInt64Array(ctx, value) ([]int64, error)` - Parse to int64 array\n\n### Default Functions\n\nAll parse functions have corresponding `ParseXDefault` variants that return a fallback value on error:\n\n- `ParseStringDefault(ctx, value, defaultValue) string`\n- `ParseIntDefault(ctx, value, defaultValue) int`\n- `ParseBoolDefault(ctx, value, defaultValue) bool`\n- etc.\n\nFull API documentation: [pkg.go.dev/github.com/bborbe/parse](https://pkg.go.dev/github.com/bborbe/parse)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbborbe%2Fparse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbborbe%2Fparse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbborbe%2Fparse/lists"}