String utilities for Go
Switch branches/tags
Clone or download
Latest commit 25745d7 Sep 6, 2018
Permalink
Failed to load latest commit information.
.circleci Add CircleCI integration Aug 16, 2018
.gitignore Update readme and make small improvements Aug 19, 2018
LICENSE
README.md Improve readme Aug 31, 2018
box.go Remove inferred types Aug 31, 2018
box_test.go Update readme, examples and docs Aug 20, 2018
case.go Move golang.org/x/text dependent functions to unicode.go Aug 21, 2018
case_benchmark_test.go Make slugify 3 times faster Aug 18, 2018
case_test.go
create.go Add Random function Aug 19, 2018
create_test.go
doc.go Fix, optimize and change functions inside whitespace.go Aug 18, 2018
info.go Improve the performance of Substring function Aug 20, 2018
info_benchmark_test.go Improve the performance of Substring function Aug 20, 2018
info_test.go
modify.go
modify_test.go Move golang.org/x/text dependent functions to unicode.go Aug 21, 2018
unicode.go
unicode_test.go Fix left trim error in Slugify Aug 21, 2018
whitespace.go Change how Align* functions works Aug 18, 2018
whitespace_test.go Change how Align* functions works Aug 18, 2018
wordwrap.go Improve docs and remove an ineffectual assignment Aug 20, 2018
wordwrap_benchmark_test.go
wordwrap_test.go Add Summary function Aug 19, 2018

README.md

String Utilities for Go

CircleCI cover.run GoReportCard GoDocs

"strutil" provides string functions for go applications.

In some functions it may not work as expected in non-latin alphabets like cyrillic, chinese, etc. Also there may be some language spesific edge cases that aren't supported well. Any help on those areas would be appreciated.

For documentation with examples see GoDoc

Functions

Function Desctiption
Align Aligns the text to the spesified side
AlignCenter Aligns the text to the center
AlignLeft Aligns the text to the left
AlignRight Aligns the text to the right
Box Draws a frame around the string with default chars
Center Centers the string
CountWords Count the words in the string
CustomBox Draws a frame around the string with specified chars
ExpandTabs Converts tabs to spaces
Indent Indents the string
MapLines Runs spesified function on every line of the text
Pad Left and right pads the strings
PadLeft Left pads the string
PadRight Right pads the string
Random Creates a random string from a character set
RemoveAccents Remove accents in the string
ReplaceAllToOne Replace all substrings in the text to the spesified string
Reverse Reverses the string
Slugify Converts the string to a slug
SplitCamelCase Splits the words in a camelCase string
ToCamelCase Converts the string to camelCase
ToSnakeCase Converts the string to snake_Case
Substring Returns a part of the string
Summary Cuts the text to the length
Splice Replaces a part of the string
Wordwrap Wraps the lines in the text

Install

Prequsities:

  • Go 1.10+

Install with

go get github.com/ozgio/strutil

Dependencies:

go get golang.org/x/text/runes
go get golang.org/x/text/transform
go get golang.org/x/text/unicode/norm

Import

import "github.com/ozgio/strutil"

TODO

  • Improve tests. More test cases are needed
  • Test for different languages
  • Handle "\r\n"
  • Improve whitespace and punctuation support