{"id":13413475,"url":"https://github.com/ozgio/strutil","last_synced_at":"2025-12-25T07:46:42.188Z","repository":{"id":34260669,"uuid":"144949393","full_name":"ozgio/strutil","owner":"ozgio","description":"String utilities for Go","archived":false,"fork":false,"pushed_at":"2022-05-25T07:15:27.000Z","size":88,"stargazers_count":203,"open_issues_count":1,"forks_count":25,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-07-31T20:52:22.995Z","etag":null,"topics":["go","golang","strings"],"latest_commit_sha":null,"homepage":null,"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/ozgio.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":"2018-08-16T06:56:15.000Z","updated_at":"2024-07-29T12:57:43.000Z","dependencies_parsed_at":"2022-08-08T00:15:13.188Z","dependency_job_id":null,"html_url":"https://github.com/ozgio/strutil","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ozgio%2Fstrutil","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ozgio%2Fstrutil/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ozgio%2Fstrutil/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ozgio%2Fstrutil/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ozgio","download_url":"https://codeload.github.com/ozgio/strutil/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243635458,"owners_count":20322942,"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","strings"],"created_at":"2024-07-30T20:01:41.222Z","updated_at":"2025-12-25T07:46:42.151Z","avatar_url":"https://github.com/ozgio.png","language":"Go","readme":"String Utilities for Go\n=======================\n[![GoReportCard](https://goreportcard.com/badge/github.com/ozgio/strutil)](https://goreportcard.com/report/github.com/ozgio/strutil)\n[![GoDocs](https://godoc.org/github.com/ozgio/strutil?status.svg)](https://godoc.org/github.com/ozgio/strutil)\n\n\"strutil\" provides string functions for go applications.\n\nFor documentation with examples see [GoDoc](https://godoc.org/github.com/ozgio/strutil)\n\n## Functions\n\n\n### Align ([Docs](https://godoc.org/github.com/ozgio/strutil#Align))\nAligns the text to the specified side\n\n```go\nstrutil.Align(\"lorem ipsum\", strutil.Right, 20) //-\u003e\"        lorem ipsum\" \n```\n\n### AlignCenter ([Docs](https://godoc.org/github.com/ozgio/strutil#AlignCenter))\nAligns the text to the center\n```go\nstrutil.AlignCenter(\"lorem\\nipsum\", 10) //-\u003e\"  lorem   \\n  ipsum   \" \n```\n\n### AlignLeft ([Docs](https://godoc.org/github.com/ozgio/strutil#AlignLeft))\nAligns the text to the left\n```go\nstrutil.AlignLeft(\"  lorem   \\n  ipsum   \") //-\u003e\"lorem   \\nipsum   \" \n```\n\n### AlignRight ([Docs](https://godoc.org/github.com/ozgio/strutil#AlignRight))\nAligns the text to the right\n```go\nstrutil.AlignRight(\"lorem\\nipsum\", 10) //-\u003e \"     lorem\\n     ipsum\" \n```\n\n### CountWords ([Docs](https://godoc.org/github.com/ozgio/strutil#CountWords))\nCounts the words\n```go\nstrutil.CountWords(\"Lorem ipsum, dolor sit amet\") //-\u003e \"5\"\n```\n\n### DrawBox ([Docs](https://godoc.org/github.com/ozgio/strutil#DrawBox))\nDraws a frame around the string with default character set\n```go\nstrutil.DrawBox(\"Hello World\", 20, strutil.Center)\n//┌──────────────────┐\n//│   Hello World    │\n//└──────────────────┘\n```\n\n### DrawCustomBox ([Docs](https://godoc.org/github.com/ozgio/strutil#DrawCustomBox))\nDraws a frame around the string with custom character set\n```go\nstrutil.DrawCustomBox(\"Hello World\", 20, strutil.Center, strutil.SimpleBox9Slice(), \"\\n\")\n//┌──────────────────┐\n//│   Hello World    │\n//└──────────────────┘\n```\n\n### ExpandTabs  ([Docs](https://godoc.org/github.com/ozgio/strutil#ExpandTabs))\nConverts tabs to the spaces\n```go\nstrutil.ExpandTabs(\"\\tlorem\\n\\tipsum\\n\", 2) //-\u003e \"  lorem\\n  ipsum\\n\"\n```\n\n### Indent ([Docs](https://godoc.org/github.com/ozgio/strutil#Indent))\nIndents every line\n```go\nstrutil.Indent(\"lorem\\nipsum\", \"\u003e \") //-\u003e \"\u003e lorem\\n\u003e ipsum\"\n```\n\n### IsASCII ([Docs](https://godoc.org/github.com/ozgio/strutil#IsASCII))\nChecks if all the characters in string are in standard ASCII table\n```go\nstrutil.IsASCII(\"lorem\\nipsum\") //-\u003e true\n```\n\n### Len ([Docs](https://godoc.org/github.com/ozgio/strutil#Len))\nAlias of utf8.RuneCountInString which returns the number of runes in string\n```go\nstrutil.Len(\"böt\") //-\u003e \"3\"\n```\n\n### MapLines ([Docs](https://godoc.org/github.com/ozgio/strutil#MapLines))\nRuns function fn on every line of the string\n```go\nstrutil.MapLines(\"   lorem      \\n    ipsum      \", strings.TrimSpace) //-\u003e \"lorem\\nipsum\"\n```\n\n### OSNewLine ([Docs](https://godoc.org/github.com/ozgio/strutil#OSNewLine))\nOSNewLine returns operating systems default new line character\n```go\nstrutil.OSNewLine() //-\u003e \"\\n\"\n```\n\n### Pad ([Docs](https://godoc.org/github.com/ozgio/strutil#Pad))\nLeft and right pads the string\n```go\nstrutil.Pad(\"lorem\", 11, \"-\u003e\", \"\u003c-\") //-\u003e \"-\u003e-\u003elorem\u003c-\u003c-\"\n```\n\n### PadLeft ([Docs](https://godoc.org/github.com/ozgio/strutil#PadLeft))\nLeft pads the string\n```go\nstrutil.PadLeft(\"lorem\", 9, \"-\u003e\") //-\u003e \"-\u003e-\u003elorem\"\n```\n\n### PadRight ([Docs](https://godoc.org/github.com/ozgio/strutil#PadRight))\nRight pads the string\n```go\nstrutil.PadRight(\"lorem\", 9, \"\u003c-\") //-\u003e \"lorem\u003c-\u003c-\"\n```\n\n### Random ([Docs](https://godoc.org/github.com/ozgio/strutil#Random))\nCreates a random string from a character set\n```go\nstrutil.Random(\"abcdefghi\", 10) //-\u003e \"aciafbeafg\"\n```\n\n### RemoveAccents ([Docs](https://godoc.org/github.com/ozgio/strutil#RemoveAccents))\nConvert accented letters to ascii counterparts\n```go\nstrutil.RemoveAccents(\"résumé\") //-\u003e \"resume\"\n```\n\n### ReplaceAllToOne ([Docs](https://godoc.org/github.com/ozgio/strutil#ReplaceAllToOne))\nReplace all substrings in the text with the specified string\n```go\nstrutil.ReplaceAllToOne(\"lorem ipsum\", []string{\"o\",\"e\",\"i\",\"u\"}, \".\") //-\u003e \"l.r.m .ps.m\"\n```\n\n### Reverse ([Docs](https://godoc.org/github.com/ozgio/strutil#Reverse))\nReverses the string\n```go\nstrutil.Reverse(\"lorem\") //-\u003e \"merol\"\n```\n\n### Splice ([Docs](https://godoc.org/github.com/ozgio/strutil#Splice))\nReplaces a part of the string \n```go\nstrutil.Splice(\"lorem\", \"-x-\", 2, 3) //-\u003e \"lo-x-em\"\n```\n\n### SplitAndMap ([Docs](https://godoc.org/github.com/ozgio/strutil#SplitAndMap))\nSplits the string and runs the function fn on every part\n```go\nstrutil.MapLines(\"lorem-ipsum-dolor\", \"-\",  strutil.Reverse) //-\u003e \"merol\\nmuspi\\nrolod\"\n```\n\n### Slugify ([Docs](https://godoc.org/github.com/ozgio/strutil#Slugify))\nConverts the string to a slug \n```go\nstrutil.Slugify(\"Lorem ipsum, dolör\") //-\u003e \"lorem-ipsum-dolor\"\n```\n\n### SlugifySpecial ([Docs](https://godoc.org/github.com/ozgio/strutil#SlugifySpecial))\nConverts the string to a slug with custom delimiter.\n```go\nstrutil.SlugifySpecial(\"Lorem ipsum, dolör\", \"_\") //-\u003e \"lorem_ipsum_dolor\"\n```\n\n### SplitCamelCase  ([Docs](https://godoc.org/github.com/ozgio/strutil#SplitCamelCase))\nSplits the words in a camelCase string\n```go\nstrutil.SplitCamelCase(\"loremIpsum\") //-\u003e []string{\"lorem\", \"Ipsum\"}\n```\n\n### Substring ([Docs](https://godoc.org/github.com/ozgio/strutil#SafeSubstring))\nGets a part of the string without panics\n```go\nstrutil.SafeSubstring(\"lorem\", 0, 1) //-\u003e \"l\"\n```\n\n### MustSubstring ([Docs](https://godoc.org/github.com/ozgio/strutil#Substring))\nGets a part of the string\n```go\nstrutil.Substring(\"lorem\", 0, 1) //-\u003e \"l\"\n```\n\n### Summary ([Docs](https://godoc.org/github.com/ozgio/strutil#Summary))\nCuts the string to the specified length\n```go\nstrutil.Summary(\"Lorem ipsum dolor sit amet\",  10, \"...\") //-\u003e \"lorem ipsum...\"\n```\n\n### Tile ([Docs](https://godoc.org/github.com/ozgio/strutil#Tile))\nRepeats the pattern until the result reaches the 'length'\n```go\nstrutil.Tile(\"-৹\", 4) //-\u003e \"-৹-৹\"\n```\n\n### ToSnakeCase  ([Docs](https://godoc.org/github.com/ozgio/strutil#ToSnakeCase))\nConverts the string to snake_case \n```go\nstrutil.ToSnakeCase(\"Snake Case\") //-\u003e \"snake_case\"\n```\n\n### ToCamelCase  ([Docs](https://godoc.org/github.com/ozgio/strutil#ToCamelCase))\nConverts the string to camelCase \n```go\nstrutil.ToCamelCase(\"Camel Case\") //-\u003e \"camelCase\"\n```\n\n### Words ([Docs](https://godoc.org/github.com/ozgio/strutil#Words))\nReturns the words inside the text\n```go\nstrutil.Words(\"Lorem ipsum, dolor sit amet\") //-\u003e []string{\"Lorem\", \"ipsum\", \"dolor\", \"sit\", \"amet\"}\n```\n\n### WordWrap ([Docs](https://godoc.org/github.com/ozgio/strutil#WordWrap))\nWraps the lines in the text  \n```go\nstrutil.WordWrap(\"Lorem ipsum dolor sit amet\", 15, false) //-\u003e \"Lorem ipsum\\ndolor sit amet\"\n```\n\n\n## Install\n\nPrequsities:\n- Go 1.10+\n\nInstall with\n```sh\ngo get github.com/ozgio/strutil\n```\n","funding_links":[],"categories":["Miscellaneous","Go","其他杂项","杂项","Microsoft Office","字符串处理库","其他","Strings"],"sub_categories":["Strings","字符串处理","字符串","Advanced Console UIs","交互工具","交流"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fozgio%2Fstrutil","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fozgio%2Fstrutil","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fozgio%2Fstrutil/lists"}