{"id":21223984,"url":"https://github.com/pdcalado/gomutate","last_synced_at":"2026-01-26T22:44:21.905Z","repository":{"id":206855358,"uuid":"716737950","full_name":"pdcalado/gomutate","owner":"pdcalado","description":"Generate code to mutate Go types","archived":false,"fork":false,"pushed_at":"2024-06-27T15:16:10.000Z","size":108,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-31T12:40:48.058Z","etag":null,"topics":["changelog-generator","code-generation","go","idempotency","mutations","mutator"],"latest_commit_sha":null,"homepage":"","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/pdcalado.png","metadata":{"files":{"readme":"README.md","changelog":"changes/changes.go","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":"2023-11-09T19:09:48.000Z","updated_at":"2024-06-27T15:16:15.000Z","dependencies_parsed_at":"2024-02-28T23:33:09.921Z","dependency_job_id":"5a123650-2fba-44fc-849b-147bb9148d27","html_url":"https://github.com/pdcalado/gomutate","commit_stats":null,"previous_names":["pdcalado/gomutate"],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pdcalado%2Fgomutate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pdcalado%2Fgomutate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pdcalado%2Fgomutate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pdcalado%2Fgomutate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pdcalado","download_url":"https://codeload.github.com/pdcalado/gomutate/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239898462,"owners_count":19715212,"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":["changelog-generator","code-generation","go","idempotency","mutations","mutator"],"created_at":"2024-11-20T22:54:24.693Z","updated_at":"2026-01-26T22:44:21.863Z","avatar_url":"https://github.com/pdcalado.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gomutate\n\n![ci workflow](https://github.com/pdcalado/gomutate/actions/workflows/ci.yml/badge.svg)\n\nGenerate code to mutate your Go types.\n\nFor a type like this:\n\n```go\ntype Acme struct {\n Name        string\n YearOfBirth int\n Employees   []*Employee\n}\n\ntype Employee struct {\n Name     string\n Position string\n JoinedAt time.Time\n}\n```\n\nGenerates code allowing you to mutate it like this:\n\n```go\nacme := Acme{\n    Name:        \"Acme Inc.\",\n    YearOfBirth: 2000,\n    Employees: []*Employee{\n        {\n            Name:     \"John Doe\",\n            Position: \"CEO\",\n            JoinedAt: time.Date(2010, 1, 1, 0, 0, 0, 0, time.UTC),\n        },\n        {\n            Name:     \"Jane Doe\",\n            Position: \"CTO\",\n            JoinedAt: time.Date(2010, 1, 1, 0, 0, 0, 0, time.UTC),\n        },\n    },\n}\n\nmutator := NewMutatorAcme(\u0026acme)\nmutator.SetYearOfBirth(2019)\nmutator.EmployeesAt(0).SetName(\"John Smith\")\n```\n\nand reporting changes like this:\n\n```go\nfmt.Println(mutator.FormatChanges())\n```\n\nwhich outputs:\n\n```\nYearOfBirth Updated: 2018 -\u003e 2019\nEmployees Name Updated: John Doe -\u003e John Smith\n```\n\n## Usage\n\n```console\ngo get github.com/pdcalado/gomutate\n```\n\n```console\ngo run github.com/pdcalado/gomutate -type \u003ctype-name\u003e -w \u003cpath-to-output-file\u003e \u003cpath-to-input-file\u003e\n```\n\nInput and output files must be in the same package. Omit the `-w` flag to print to stdout.\n\n## Features\n\nSee our [tests](./testdata/main.go) for examples of other possibly unlisted supported operations.\n\n- operations with pointers and basic types are idempotent (the same mutation performed twice must only report one change)\n- a custom formatter and custom change logger can be provided\n- mutate a field with basic type\n- mutate a field with a slice or map of basic types\n- mutate a field with a slice of structs or struct pointers defined in the same package\n- mutate a field with a map of structs or struct pointers defined in the same package, including struct pointers as keys\n- append and delete from a slice\n- insert and delete from a map\n\n## Limitations\n\n- Only supports structs\n- Only supports chaining mutators for types defined in the same package\n- Only supports types with exported fields\n- Does not support nested slices or maps, like `[][]string` or `map[string]map[int]string`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpdcalado%2Fgomutate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpdcalado%2Fgomutate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpdcalado%2Fgomutate/lists"}