{"id":15109803,"url":"https://github.com/automattic/go-search-replace","last_synced_at":"2025-04-05T18:09:45.860Z","repository":{"id":48692704,"uuid":"106839521","full_name":"Automattic/go-search-replace","owner":"Automattic","description":"🚀 Search \u0026 replace URLs in WordPress SQL files.","archived":false,"fork":false,"pushed_at":"2025-04-04T18:13:51.000Z","size":102,"stargazers_count":96,"open_issues_count":6,"forks_count":19,"subscribers_count":10,"default_branch":"trunk","last_synced_at":"2025-04-05T18:09:39.723Z","etag":null,"topics":["golang","text-processing","wordpress"],"latest_commit_sha":null,"homepage":"https://wpvip.com/2018/03/28/data-sync-on-vip-go/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Automattic.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":"2017-10-13T15:09:08.000Z","updated_at":"2025-04-04T18:12:27.000Z","dependencies_parsed_at":"2024-02-08T06:28:42.069Z","dependency_job_id":"c0c6487e-60d9-4767-be2c-982d29fc5377","html_url":"https://github.com/Automattic/go-search-replace","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Automattic%2Fgo-search-replace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Automattic%2Fgo-search-replace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Automattic%2Fgo-search-replace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Automattic%2Fgo-search-replace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Automattic","download_url":"https://codeload.github.com/Automattic/go-search-replace/tar.gz/refs/heads/trunk","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247378149,"owners_count":20929297,"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":["golang","text-processing","wordpress"],"created_at":"2024-09-25T23:24:10.024Z","updated_at":"2025-04-05T18:09:45.841Z","avatar_url":"https://github.com/Automattic.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go Search Replace\n\n[![Build Status](https://travis-ci.org/Automattic/go-search-replace.svg?branch=master)](https://travis-ci.org/Automattic/go-search-replace)\n\nSearch \u0026 replace URLs in WordPress SQL files.\n\n```\ncat example-from.com.sql | search-replace example-from.com example-to.com \u003e example-to.com.sql\n```\n\n## Overview\n\nMigrating WordPress databases often requires replacing domain names. This is a\ncomplex operation because WordPress stores PHP serialized data, which encodes\nstring lengths. The common method uses PHP to unserialize the data, do the\nsearch/replace, and then re-serialize the data before writing it back to the\ndatabase. Here we replace strings in the SQL file and then fix the string\nlengths.\n\n## Considerations\n\nReplacing strings in a SQL file can be dangerous. We have to be careful not to\nmodify the structure of the file in a way that would corrupt the file. For this\nreason, we're limiting the search domain to roughly include characters that can\nbe used in domain names. Since the most common usage for search-replace is\nchanging domain names or switching http: to https:, this is an easy way to avoid\notherwise complex issues.\n\n## Installation\n\n### From Official Releases\n\nTo install on macOS:\n\n```\nwget https://github.com/Automattic/go-search-replace/releases/latest/download/go-search-replace_darwin_arm64.gz\ngunzip go-search-replace_darwin_arm64.gz\nchmod +x go-search-replace_darwin_arm64\nmv go-search-replace_darwin_arm64 /usr/local/bin/go-search-replace\ngo-search-replace --version\n```\n\n### From Source\n\nTo install from source, this package requires [Go](https://golang.org/).\n\nNote the changes you need to make to your PATH and that you have to either restart your terminal or `source` your shell rc file.\n\nYou need to install Gox which you can install with\n`go install github.com/mitchellh/gox@latest`\n\nOnce that's installed you can install this tool with the following command:\n`go install github.com/Automattic/go-search-replace@latest`\n\nGo is set up by convention, not configuration so your files likely live in a directory like: /Users/user/go/src/github.com/Automattic/go-search-replace\n\nNagivage to that directory and run\n`make`\n\n`go-search-replace` will be ready for you to use. Once built you won't have to complete any of the above steps again.\n\n## Package Usage\n\nTo use it as a package in your Go project, you can install it with the following command:\n\n```\ngo get github.com/Automattic/go-search-replace\n```\n\nOnce you've installed the package, you can use the `searchreplace` package in your project. Here's an example:\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/Automattic/go-search-replace/searchreplace\"\n)\n\nfunc main() {\n\tinput := []byte(`s:3:\\\"foo\\\";`)\n\n\tresult := searchreplace.FixLine(\u0026input, []*searchreplace.Replacement{\n\t\t{\n\t\t\tFrom: []byte(\"foo\"),\n\t\t\tTo:   []byte(\"Hello, Gophers!\"),\n\t\t},\n\t})\n\n\tfmt.Println(string(*result))\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fautomattic%2Fgo-search-replace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fautomattic%2Fgo-search-replace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fautomattic%2Fgo-search-replace/lists"}