{"id":13461335,"url":"https://github.com/go-faker/faker","last_synced_at":"2025-03-24T22:34:31.877Z","repository":{"id":38208577,"uuid":"501482816","full_name":"go-faker/faker","owner":"go-faker","description":"Go (Golang) Fake Data Generator for Struct, previously https://github.com/bxcodec/faker","archived":false,"fork":false,"pushed_at":"2025-02-05T09:17:45.000Z","size":213,"stargazers_count":738,"open_issues_count":18,"forks_count":36,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-18T22:38:00.926Z","etag":null,"topics":["fake-data","faker","golang","golang-library","testing-library","testing-tools"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/go-faker/faker/v4","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/go-faker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":["bxcodec"]}},"created_at":"2022-06-09T02:50:41.000Z","updated_at":"2025-03-17T07:27:34.000Z","dependencies_parsed_at":"2024-03-29T23:36:36.763Z","dependency_job_id":"e3b4339d-bcf4-4e65-b8c5-984f38a80f2b","html_url":"https://github.com/go-faker/faker","commit_stats":{"total_commits":16,"total_committers":6,"mean_commits":"2.6666666666666665","dds":0.4375,"last_synced_commit":"5effebba7fe9e25350305432ffdca5e19151edad"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-faker%2Ffaker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-faker%2Ffaker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-faker%2Ffaker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-faker%2Ffaker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/go-faker","download_url":"https://codeload.github.com/go-faker/faker/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245366184,"owners_count":20603438,"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":["fake-data","faker","golang","golang-library","testing-library","testing-tools"],"created_at":"2024-07-31T11:00:34.759Z","updated_at":"2025-03-24T22:34:31.592Z","avatar_url":"https://github.com/go-faker.png","language":"Go","funding_links":["https://github.com/sponsors/bxcodec"],"categories":["Go","开源类库","Open source library"],"sub_categories":["测试","Test"],"readme":"# Docs\n\n## [faker](#)\n\nStruct Data Fake Generator\n\nFaker will generate you a fake data based on your Struct.\n\n[![Go Test](https://github.com/go-faker/faker/actions/workflows/go.yml/badge.svg)](https://github.com/go-faker/faker/actions/workflows/go.yml)\n[![codecov](https://codecov.io/gh/go-faker/faker/branch/main/graph/badge.svg)](https://codecov.io/gh/go-faker/faker)\n[![Go Report Card](https://goreportcard.com/badge/github.com/go-faker/faker/v4)](https://goreportcard.com/report/github.com/go-faker/faker/v4)\n[![License](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/go-faker/faker/blob/master/LICENSE)\n[![Go.Dev](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go\u0026logoColor=white)](https://pkg.go.dev/github.com/go-faker/faker/v4?tab=doc)\n\n## Index\n\n- [Support](#support)\n- [Getting Started](#getting-started)\n- [Example](#example)\n- [Limitation](#limitation)\n- [Contribution](#contribution)\n\n## Support\n\nYou can file an [Issue](https://github.com/go-faker/faker/issues/new).\nSee documentation in [Go.Dev](https://pkg.go.dev/github.com/go-faker/faker/v4?tab=doc)\n\n## Getting Started\n\n#### Download\n\n```shell\ngo get -u github.com/go-faker/faker/v4\n```\n\n# Example\n\n---\n\n- Using Struct's tag:\n  - [basic tags: example_with_tags_test.go](/example_with_tags_test.go)\n  - [length and bounds: example_with_tags_lenbounds_test.go](/example_with_tags_lenbounds_test.go)\n  - [language: example_with_tags_lang_test.go](/example_with_tags_lang_test.go)\n  - [unique: example_with_tags_unique_test.go](example_with_tags_unique_test.go)\n  - [slice length: example_with_tags_slicelength_test.go](example_with_tags_slicelength_test.go)\n- Custom Struct's tag (define your own faker data): [example_custom_faker_test.go](/example_custom_faker_test.go)\n- Without struct's tag: [example_without_tag_test.go](/example_without_tag_test.go)\n- Single Fake Data Function: [example_single_fake_data_test.go](/example_single_fake_data_test.go)\n\n## DEMO\n\n---\n\n![Example to use Faker](https://cdn-images-1.medium.com/max/800/1*AkMbxngg7zfvtWiuvFb4Mg.gif)\n\n## Benchmark\n\n---\n\nBench To Generate Fake Data\n\n#### Without Tag\n\n```bash\nBenchmarkFakerDataNOTTagged-4             500000              3049 ns/op             488 B/op         20 allocs/op\n```\n\n#### Using Tag\n\n```bash\n BenchmarkFakerDataTagged-4                100000             17470 ns/op             380 B/op         26 allocs/op\n```\n\n### MUST KNOW\n\n---\n\nThe Struct Field must be PUBLIC.\u003cbr\u003e\nSupport Only For :\n\n- `int`, `int8`, `int16`, `int32` \u0026 `int64`\n- `[]int`, `[]int8`, `[]int16`, `[]int32` \u0026 `[]int64`\n- `bool` \u0026 `[]bool`\n- `string` \u0026 `[]string`\n- `float32`, `float64`, `[]float32` \u0026`[]float64`\n- `time.Time` \u0026 `[]time.Time`\n- Nested Struct Field\n\n## Limitation\n\n---\n\nUnfortunately this library has some limitation\n\n- It does not support private fields. Make sure your structs fields you intend to generate fake data for are public, it would otherwise trigger a panic. You can however omit fields using a tag skip `faker:\"-\"` on your private fields.\n- It does not support the `interface{}` data type. How could we generate anything without knowing its data type?\n- It does not support the `map[interface{}]interface{}`, `map[any_type]interface{}` \u0026 `map[interface{}]any_type` data types. Once again, we cannot generate values for an unknown data type.\n- Custom types are not fully supported. However some custom types are already supported: we are still investigating how to do this the correct way. For now, if you use `faker`, it's safer not to use any custom types in order to avoid panics.\n- Some extra custom types can be supported IF AND ONLY IF extended with [AddProvider()](https://github.com/go-faker/faker/blob/7473ac7d8d0440d24addac302c73e13c08895764/faker.go#L303) please see [example](example_custom_faker_test.go#L46)\n- The `oneof` tag currently only supports `string`, the `int` types, and both `float32` \u0026 `float64`. Further support is coming soon (i.e. hex numbers, etc). See [example](example_with_tags_test.go#L53) for usage.\n\n## Contribution\n\n---\n\nTo contrib to this project, you can open a PR or an issue.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-faker%2Ffaker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgo-faker%2Ffaker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-faker%2Ffaker/lists"}