{"id":19836539,"url":"https://github.com/wawandco/fako","last_synced_at":"2025-04-06T10:13:49.360Z","repository":{"id":48268695,"uuid":"46071020","full_name":"wawandco/fako","owner":"wawandco","description":"Struct Faker for Go","archived":false,"fork":false,"pushed_at":"2018-08-28T01:02:51.000Z","size":274,"stargazers_count":345,"open_issues_count":1,"forks_count":12,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-30T09:07:50.475Z","etag":null,"topics":["faker","go","struct","stub","testing"],"latest_commit_sha":null,"homepage":"http://wawand.co","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/wawandco.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}},"created_at":"2015-11-12T18:06:04.000Z","updated_at":"2025-03-04T10:39:21.000Z","dependencies_parsed_at":"2022-09-02T00:02:33.064Z","dependency_job_id":null,"html_url":"https://github.com/wawandco/fako","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wawandco%2Ffako","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wawandco%2Ffako/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wawandco%2Ffako/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wawandco%2Ffako/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wawandco","download_url":"https://codeload.github.com/wawandco/fako/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247464224,"owners_count":20942970,"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":["faker","go","struct","stub","testing"],"created_at":"2024-11-12T12:11:38.521Z","updated_at":"2025-04-06T10:13:49.330Z","avatar_url":"https://github.com/wawandco.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"### Fako\n\n[![Circle CI](https://circleci.com/gh/wawandco/fako.svg?style=svg)](https://circleci.com/gh/wawandco/fako) [![Godoc](https://img.shields.io/badge/godoc-docs-blue.svg)](https://godoc.org/github.com/wawandco/fako)\n[![Go Report Card](https://goreportcard.com/badge/github.com/wawandco/fako)](https://goreportcard.com/report/github.com/wawandco/fako)\n\n**Fako** is a library intended to fake Golang structs with fake but coherent data, **Fako** maps struct field tags and generates fake data accordingly.\n\nWe find it useful when writing specs to generate fake database data, hope you too.\n\n#### Example\n\nThis is an example of how **Fako** works.\n\n```go\nimport(\n  \"fmt\"\n  \"github.com/wawandco/fako\"\n)\n\ntype User struct {\n    Name     string `fako:\"full_name\"`\n  \tUsername string `fako:\"user_name\"`\n  \tEmail    string `fako:\"email_address\"`//Notice the fako:\"email_address\" tag\n  \tPhone    string `fako:\"phone\"`\n  \tPassword string `fako:\"simple_password\"`\n  \tAddress  string `fako:\"street_address\"`\n}\n\nfunc main(){\n  var user User\n  fako.Fill(\u0026user)\n\n  fmt.Println(\u0026user.Email)\n  // This prints something like AnthonyMeyer@Twimbo.biz\n  // or another valid email\n\n  var userWithOnlyEmail User\n  fako.FillOnly(\u0026userWithOnlyEmail, \"Email\")\n  //This will fill all only the email\n\n  var userWithoutEmail User\n  fako.FillExcept(\u0026userWithoutEmail, \"Email\")\n  //This will fill all the fields except the email\n\n}\n```\n\nFako provides 3 built in functions `Fill`, `FillOnly`, and `FillExcept`, please go to [godoc](https://godoc.org/github.com/wawandco/fako) for details.\n\n**Fako** support most of the fields on the [fake](https://github.com/icrowley/fake)  library, below you can see a list of the field types you can use.\n\n- brand\n- character\n- characters\n- city\n- color\n- company\n- continent\n- country\n- credit_card_type\n- currency\n- currency_code\n- digits\n- domain_name\n- domain_zone\n- email_address\n- email_body\n- email_subject\n- female_first_name\n- female_full_name\n- female_full_name_with_prefix\n- female_full_name_with_suffix\n- female_last_name\n- female_patronymic\n- first_name\n- full_name\n- full_name_with_prefix\n- full_name_with_suffix\n- gender\n- gender_abbrev\n- hex_color\n- hex_color_short\n- ip_v4\n- industry\n- job_title\n- language\n- last_name\n- latitude_direction\n- longitude_direction\n- male_first_name\n- male_full_name\n- male_full_name_with_prefix\n- male_full_name_with_suffix\n- male_last_name\n- male_patronymic\n- model\n- month\n- month_short\n- paragraph\n- paragraphs\n- patronymic\n- phone\n- product\n- product_name\n- sentence\n- sentences\n- simple_password\n- state\n- state_abbrev\n- street\n- street_address\n- title\n- top_level_domain\n- user_name\n- week_day\n- week_day_short\n- word\n- words\n- zip\n\n#### Custom Generators\n\nFako provides a function called `Register` to add custom data generators in case you need something that our provided generators cannot cover.\n\nTo add a custom generator simply call the `Register` function as in the following example:\n\n```go\nimport(\n  \"fmt\"\n  \"github.com/wawandco/fako\"\n)\n\ntype User struct {\n    Name     string `fako:\"full_name\"`\n    Username string `fako:\"user_name\"`\n    Email    string `fako:\"email_address\"`//Notice the fako:\"email_address\" tag\n    Phone    string `fako:\"phone\"`\n    Password string `fako:\"simple_password\"`\n    Address  string `fako:\"street_address\"`\n\n    AValue   string `fako:\"a_gen\"`\n}\n\nfunc main(){\n  fako.Register(\"a_gen\", func() string {\n    return \"My Value\"\n  })\n\n  var user User\n  fako.Fill(\u0026user)\n  fmt.Println(user.AValue) //should print My Value\n}\n```\n\nWhen using custom generators please keep the following in mind:\n  1. Call Register function before calling `Fill` and its brothers.\n  2. Custom generators override base generators, if you pick the same name as one of the existing generators, we will override the existing generator with yours.\n\n\n#### Fuzzing\n\nSometimes you just want to generate random data inside a struct, for those cases you wont want to fill fako types (yes, we understand that part). Fako provides you a `Fuzz` function you can use to fuzz your structs with random data that simply matches the struct's field types.\n\nYou can use it as in the following example:\n\n```go\nimport \"fako\"\n\ntype Instance struct {\n   Name string\n   Number int\n}\n\nfunc main(){\n  instance := Instance{}\n  fako.Fuzz(\u0026instance) // This fills your instance variable\n}\n```\n\nNote, Fuzz function works for the following types `string, bool, int, int32, int64, float32, float64`. other types like `Array` or `Chan` are out of our scope.\n\n#### Credits\nAs you may have noticed this is based on [fake](https://github.com/icrowley/fake) library, which does all the work to generate data.\n\n#### Copyright\nFako is Copyright © 2008-2015 Wawandco SAS. It is free software, and may be redistributed under the terms specified in the LICENSE file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwawandco%2Ffako","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwawandco%2Ffako","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwawandco%2Ffako/lists"}