{"id":13413845,"url":"https://github.com/m1/gospin","last_synced_at":"2025-04-30T22:09:50.680Z","repository":{"id":51391896,"uuid":"172103483","full_name":"m1/gospin","owner":"m1","description":"Article spinning and spintax/spinning syntax engine written in Go, useful for A/B, testing pieces of text/articles and creating more natural conversations","archived":false,"fork":false,"pushed_at":"2021-05-12T09:29:11.000Z","size":2276,"stargazers_count":59,"open_issues_count":3,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-30T22:09:37.586Z","etag":null,"topics":["go","golang","golang-library","hacktoberfest","spinning-syntax","spintax"],"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/m1.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2019-02-22T17:04:51.000Z","updated_at":"2024-10-08T02:19:44.000Z","dependencies_parsed_at":"2022-09-10T23:33:30.551Z","dependency_job_id":null,"html_url":"https://github.com/m1/gospin","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m1%2Fgospin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m1%2Fgospin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m1%2Fgospin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m1%2Fgospin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/m1","download_url":"https://codeload.github.com/m1/gospin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251789612,"owners_count":21644085,"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":["go","golang","golang-library","hacktoberfest","spinning-syntax","spintax"],"created_at":"2024-07-30T20:01:51.031Z","updated_at":"2025-04-30T22:09:50.647Z","avatar_url":"https://github.com/m1.png","language":"Go","funding_links":[],"categories":["Template Engines","模板引擎","Repositories","模板引擎`模版渲染和模版生成处理库`","Relational Databases"],"sub_categories":["HTTP Clients","HTTP客户端","查询语"],"readme":"# GoSpin\n\n[![GoDoc](https://godoc.org/github.com/m1/gospin?status.svg)](https://godoc.org/github.com/m1/gospin)\n[![Build Status](https://travis-ci.org/m1/gospin.svg?branch=master)](https://travis-ci.org/m1/gospin)\n[![Go Report Card](https://goreportcard.com/badge/github.com/m1/gospin)](https://goreportcard.com/report/github.com/m1/gospin)\n[![Release](https://img.shields.io/github/release/m1/gospin.svg)](https://github.com/m1/gospin/releases/latest)\n[![Coverage Status](https://coveralls.io/repos/github/m1/gospin/badge.svg)](https://coveralls.io/github/m1/gospin)\n\n__Article spinning and spintax/spinning syntax engine written in Go, useful for A/B, testing pieces of text/articles and creating more natural conversations. \nUse as a [library](#usage) or as a [CLI](#cli-usage).__\n\n## Installation\n\nUse go get to get the latest version\n```text\ngo get github.com/m1/gospin\n```\n\nThen import it into your projects using the following:\n```go\nimport (\n\t\"github.com/m1/gospin\"\n)\n```\n\n## What is spintax?\n\nTake this example:\n\n```\n{hello|hey} world\n```\n\nWhen spinning an article (the above sentence) each of the words/phrases contained within the curly brackets \nare randomly picked and substituted in the sentence. So for example, the above article could be spun to be:\n`hey world` and `hello world`\n\nYou can also have nested spintax, take this example:\n\n```\n{hello|hey} world, {hope {you're|you are} {okay|good}|have a nice day}\n```\n\nA few examples of what the above could output:\n- `hey world, hope you're okay`\n- `hello world, hope you are good`\n- `hello world, have a nice day`\n- etc...\n\nYou can also have optional phrases, just don't specify a word after or before a pipe to make it optional:\n```\n{hello|hey}{ world|}, how are you today?\n```\n\nA few examples of what the above could output:\n- `hey, how are you today?`\n- `hello world, how are you today?`\n- etc...\n\n## Why use spintax?\n\nSpintax can be used for several things. It used to be used a lot for spinning articles for SEO but is \nless useful for that these days. It's more used for A/B testing, testing pieces of text for efficiency/click through rate. \nAlso it is used spinning content for users to keep things fresh, i.e home page text or ai/chat bots.\n\n## Usage\n\nTo use as a library is pretty simple:\n\n```go\nspinner := gospin.New(nil)\nsimple := \"The {slow|quick} {fox|deer} {gracefully |}jumps over the {sleeping|lazy} dog\"\n\nspin := spinner.Spin(simple) // The slow fox jumps over the sleeping dog\nspins := spinner.SpinN(simple, 10)\n// spins = [\n// \"The slow fox gracefully jumps over the lazy dog\"\n// \"The slow deer jumps over the sleeping dog\"\n// \"The quick fox jumps over the lazy dog\"\n// ...\n// ]\n```\n\nYou can also configure it to take custom syntax (the package uses Jet format as the default), e.g. if you \nwanted it to set the start and end characters (default are curly brackets) to square brackets:\n```go\nspinner := gospin.New(\u0026gospin.Config{\n        StartChar:     \"[\",\n        EndChar:       \"]\",\n        DelimiterChar: \";\",\n})\nsimple := \"The [slow;quick] [fox;deer] [gracefully ;]jumps over the [sleeping;lazy] dog\"\nspin := spinner.Spin(simple) // The slow fox jumps over the sleeping dog\n```\n\n### Escaping\n\nTo escape, the default character to use is `\\\\`, e.g:\n\n```\nThe \\{slow|quick\\} {fox|deer} {gracefully |}jumps over the {sleeping|lazy} dog\n```\n\nWould output something like:\n```\nThe {slow|quick} fox jumps over the sleeping dog\n```\n\nYou can customize the escape char in the config:\n```go\nspinner := gospin.New(\u0026gospin.Config{\n        EscapeChar:    \"@\",\n})\nsimple := \"The @{slow|quick@} {fox|deer} {gracefully |}jumps over the {sleeping|lazy} dog\"\nspin := spinner.Spin(simple) // The @{slow|quick@} fox jumps over the sleeping dog\n```\n\n### Random seeds\n\nThe `spin` by default generates a random seed each spin, to stop this and use your own global rand seed you can \nuse the `UseGlobalRand` toggle in the config. This is useful for testing:\n\n```go\nspinner := gospin.New(\u0026gospin.Config{\n        UseGlobalRand: false,\n})\n```\n\n## CLI usage\n \nGoSpin can also be used on the cli, just install using: `go get github.com/m1/gospin/cmd/gospin`\n\nTo use:\n```\n➜  ~ gospin --help                    \nGoSpin is a fast and configurable article spinning and spintax engine written in Go.\n\nUsage:\n  gospin [text] [flags]\n\nFlags:\n      --delimiter string   Delimiter char (default \"|\")\n      --end string         End char for the spinning engine (default \"}\")\n      --escape string      Escape char (default \"\\\\\")\n  -h, --help               help for gospin\n      --start string       Start char for the spinning engine (default \"{\")\n      --times int          How many articles to generate (default 1)\n```\n\nFor example: \n```\n➜  ~ gospin \"{hello|hey} friend\"                     \nhey friend\n```\n\nTo spin multiple, use the `times` flag, this is outputted as json for easier parsing:\n```\n➜  ~ gospin \"The {slow|quick} {fox|deer} {gracefully |}jumps over the {sleeping|lazy} dog\" --times=5 | jq\n[\n  \"The slow fox gracefully jumps over the sleeping dog\",\n  \"The slow deer jumps over the lazy dog\",\n  \"The quick deer jumps over the sleeping dog\",\n  \"The slow fox gracefully jumps over the sleeping dog\",\n  \"The quick fox jumps over the lazy dog\"\n]\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm1%2Fgospin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fm1%2Fgospin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm1%2Fgospin/lists"}