{"id":19095675,"url":"https://github.com/insei/cast","last_synced_at":"2025-02-22T08:27:51.749Z","repository":{"id":241073080,"uuid":"804235227","full_name":"Insei/cast","owner":"Insei","description":"Cast is string casting library, support cast string to generic type, reflect type and value type","archived":false,"fork":false,"pushed_at":"2024-07-08T20:07:40.000Z","size":25,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-03T00:14:16.088Z","etag":null,"topics":["cast","casting","go","golang","string","string-manipulation"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Insei.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":"2024-05-22T07:59:11.000Z","updated_at":"2024-07-11T20:39:58.000Z","dependencies_parsed_at":"2024-06-19T14:34:28.056Z","dependency_job_id":"f4f301c1-e3fc-4a39-a014-bc483a1bd5ac","html_url":"https://github.com/Insei/cast","commit_stats":null,"previous_names":["insei/cast"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Insei%2Fcast","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Insei%2Fcast/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Insei%2Fcast/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Insei%2Fcast/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Insei","download_url":"https://codeload.github.com/Insei/cast/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240145940,"owners_count":19755184,"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":["cast","casting","go","golang","string","string-manipulation"],"created_at":"2024-11-09T03:34:44.584Z","updated_at":"2025-02-22T08:27:51.719Z","avatar_url":"https://github.com/Insei.png","language":"Go","readme":"[![codecov](https://codecov.io/github/Insei/cast/graph/badge.svg?token=KPPYANT85P)](https://codecov.io/github/Insei/cast)\n[![build](https://github.com/insei/cast/actions/workflows/go.yml/badge.svg)](https://github.com/Insei/cast/actions/workflows/go.yml)\n[![Goreport](https://goreportcard.com/badge/github.com/insei/cast)](https://goreportcard.com/report/github.com/insei/cast)\n[![GoDoc](https://godoc.org/github.com/insei/cast?status.svg)](https://godoc.org/github.com/insei/cast)\n# Cast\nCast is string casting library, support cast string to generic type, reflect type and value type.\n\n## Installation\nInstall via `go get`. Note that Go 1.18 or newer is required.\n```bash\ngo get github.com/Insei/cast@latest\n```\n## Contribution\nFeel free to contribute\n## Supported types\n```\n(*)int\n(*)int8\n(*)int16\n(*)int32\n(*)int64\n(*)uint\n(*)uint8\n(*)uint16\n(*)uint32\n(*)uint64\n(*)float32\n(*)float64\n(*)bool\n(*)string\n(*)time.Time\n(*)uuid.UUID (Google)\n```\n## Examples\n`To[int]` example.\n```go\nvalInt, err := cast.To[int](\"56\")\n// or valPtrInt, err := To[*int](\"56\")\nif err != nil {\n\tpanic(err)\n}\n```\n`To[time.Time]` example (supports strings only in time.RFC3339).\n```go\nvalTime, err := cast.To[time.Time](\"2024-05-22T11:36:57+03:00\")\n// or valPtrTime, err := To[*time.Time](\"2024-05-22T11:36:57+03:00\")\nif err != nil {\n\tpanic(err)\n}\n```\n`ToReflect(string, reflect.Type)` example.\n```go\ntimeType := reflect.TypeOf(time.Time{})\nvalTime, err := cast.ToReflect(\"2024-05-22T11:36:57+03:00\", timeType)\n// or valPtrTime, err := ToReflect(\"2024-05-22T11:36:57+03:00\", reflect.PointerTo(timeType))\nif err != nil {\n\tpanic(err)\n}\n```\n`ToFrom(string, any)` example.\n```go\ndate := time.Time{}\nerr := cast.ToFrom(\"2024-05-22T11:36:57+03:00\", \u0026date)\nif err != nil {\n\tpanic(err)\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finsei%2Fcast","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finsei%2Fcast","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finsei%2Fcast/lists"}