{"id":13414121,"url":"https://github.com/shockerli/cvt","last_synced_at":"2025-05-15T02:33:05.639Z","repository":{"id":42110669,"uuid":"345860757","full_name":"shockerli/cvt","owner":"shockerli","description":"Easy and safe convert any value to another type in Go. （Go 数据类型安全转换）","archived":false,"fork":false,"pushed_at":"2023-12-20T12:00:31.000Z","size":5773,"stargazers_count":47,"open_issues_count":0,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-07-31T20:53:32.765Z","etag":null,"topics":["cast","convert","cvt","go","golang","helper","toolkit"],"latest_commit_sha":null,"homepage":"https://cvt.shockerli.net","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/shockerli.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":"2021-03-09T02:38:50.000Z","updated_at":"2024-06-07T01:25:00.000Z","dependencies_parsed_at":"2023-01-24T05:31:40.568Z","dependency_job_id":"27b03690-c035-46b3-92cc-a1fe368491f3","html_url":"https://github.com/shockerli/cvt","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shockerli%2Fcvt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shockerli%2Fcvt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shockerli%2Fcvt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shockerli%2Fcvt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shockerli","download_url":"https://codeload.github.com/shockerli/cvt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254262545,"owners_count":22041441,"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","convert","cvt","go","golang","helper","toolkit"],"created_at":"2024-07-30T20:01:58.239Z","updated_at":"2025-05-15T02:33:04.870Z","avatar_url":"https://github.com/shockerli.png","language":"Go","readme":"# cvt\n\n[![PkgGoDev](https://pkg.go.dev/badge/github.com/shockerli/cvt)](https://pkg.go.dev/github.com/shockerli/cvt)\n[![Go Report Card](https://goreportcard.com/badge/github.com/shockerli/cvt)](https://goreportcard.com/report/github.com/shockerli/cvt)\n[![Build Status](https://travis-ci.com/shockerli/cvt.svg?branch=master)](https://travis-ci.com/shockerli/cvt)\n[![codecov](https://codecov.io/gh/shockerli/cvt/branch/master/graph/badge.svg)](https://codecov.io/gh/shockerli/cvt)\n![GitHub](https://img.shields.io/github/license/shockerli/cvt)\n[![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go)\n\n\u003e Simple, safe conversion of any type, including indirect/custom types.\n\n\n## Documents\nhttps://cvt.shockerli.net\n\n\n## Install\n\u003e Go \u003e= 1.13\n\n```go\ngo get -u github.com/shockerli/cvt\n```\n\n## Usage\n\nEnglish | [中文](README_ZH.md)\n\n### with `error`\n\n\u003e Method `__E()`: expect handle error, while unable to convert\n\n```go\ncvt.IntE(\"12\")          // 12, nil\ncvt.Float64E(\"12.34\")   // 12.34, nil\ncvt.StringE(12.34)      // \"12.34\", nil\ncvt.BoolE(\"false\")      // false, nil\n```\n\n### custom type and pointers\n\n\u003e dereferencing pointer and reach the original type\n\n```go\ntype Name string\n\nvar name Name = \"jioby\"\n\ncvt.StringE(name)       // jioby, nil\ncvt.StringE(\u0026name)      // jioby, nil\n```\n\n### ignore `error`\n\n\u003e Method `__()`: ignore error, while convert failed, will return the zero value of type\n\n```go\ncvt.Int(\"12\")           // 12(success)\ncvt.Int(struct{}{})     // 0(failed)\n```\n\n### with default\n\n\u003e return the default value, while convert failed\n\n```go\ncvt.Int(struct{}{}, 12)     // 12\ncvt.Float(\"hello\", 12.34)   // 12.34\n```\n\n### more\n\n\u003e 1000+ unit test cases, for more examples, see `*_test.go`\n\n\n## License\n\nThis project is under the terms of the [MIT](LICENSE) license.\n\n## Thanks\n- [JetBrains Open Source Support](https://jb.gg/OpenSourceSupport)\n\n![JetBrains Logo (Main) logo](https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.svg)\n","funding_links":[],"categories":["开源类库","Open source library","Utilities","常用工具","公用事业公司","Utility"],"sub_categories":["开发辅助包","Development Aid Package","Fail injection","Utility/Miscellaneous","爬虫工具","实用程序/Miscellaneous"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshockerli%2Fcvt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshockerli%2Fcvt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshockerli%2Fcvt/lists"}