package module
Version: v0.0.0-...-35e769f Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Sep 24, 2018 License: MIT Imports: 1 Imported by: 0


Build Status Go Report Card GoDoc license


A set of chain-able string helpers to reduce the pain of manipulating strings.


go get
# or use dep, vgo, glide or anything else


Implemented Methods
  • ReplaceN
  • ReplaceAll
  • ToLower
  • ToUpper
  • TrimPrefix
  • TrimSuffix
  • TrimSpaces
  • TrimPrefixSpaces
  • TrimSuffixSpaces
  • HasPrefix
  • HasSuffix
  • Equals
  • IsEmpty
  • IsBlank
  • Contains
  • Len
  • Index
  • LastIndex
  • Map
  • Filter
  • GetString
package main

import (


func main() {
	str := stringish.New("  hello there ")
	str.TrimSpaces().Map(func(char string) string {
		return strings.ToUpper(char)
	log.Println(str.GetString()) // "HELLO THERE"
	log.Println(str.Replace("HELLO", "bye").Contains("bye")) // true
	log.Println(str.GetString()) // "bye THERE"

Ideas || Issues

Just create an issue and describe it. I'll check it ASAP!


You can fork the repository, improve or fix some part of it and then send the pull requests back (with some tests ofc) if you want to see them here. I really appreciate that. ❤️




This section is empty.


This section is empty.


This section is empty.


type Stringish

type Stringish struct {
	// contains filtered or unexported fields

Stringish is the main exposed type with all implemented methods

func New

func New(str string) *Stringish

New creates an instance of Stringish and returns a pointer to it

func NewFromByteSlice

func NewFromByteSlice(bytes []byte) *Stringish

NewFromByteSlice creates an instance of Stringish from a slice of bytes and returns a pointer to it

func (*Stringish) Contains

func (s *Stringish) Contains(str string) bool

Contains returns true if string contains the str value

func (*Stringish) Equals

func (s *Stringish) Equals(str string) bool

Equals returns true if string equals str

func (*Stringish) Filter

func (s *Stringish) Filter(filterer func(string) bool) *Stringish

Filter runs filterer on characters of the string and holds the character if the filterer returns true

func (*Stringish) GetString

func (s *Stringish) GetString() string

GetString returns the final string result

func (*Stringish) HasPrefix

func (s *Stringish) HasPrefix(prefix string) bool

HasPrefix returns true if string starts with prefix

func (*Stringish) HasSuffix

func (s *Stringish) HasSuffix(suffix string) bool

HasSuffix returns true if string ends with suffix

func (*Stringish) Index

func (s *Stringish) Index(str string) int

Index returns the index of first occurrence of str in string (-1 if no occurrence found)

func (*Stringish) IsBlank

func (s *Stringish) IsBlank() bool

IsBlank returns true if string is blank (equal to "" or some space chars like " ")

func (*Stringish) IsEmpty

func (s *Stringish) IsEmpty() bool

IsEmpty returns true if string is empty (strictly equal to "")

func (*Stringish) LastIndex

func (s *Stringish) LastIndex(str string) int

LastIndex returns the index of last occurrence of str in string (-1 if no occurrence found)

func (*Stringish) Len

func (s *Stringish) Len() int

Len returns the len of the string

func (*Stringish) Map

func (s *Stringish) Map(mapper func(string) string) *Stringish

Map maps every character of string with given function and replace them with return value of the function

func (*Stringish) ReplaceAll

func (s *Stringish) ReplaceAll(old, new string) *Stringish

ReplaceAll replaces all occurrences of old with new

func (*Stringish) ReplaceN

func (s *Stringish) ReplaceN(old, new string, count int) *Stringish

ReplaceN replaces old with new with limit of count time[s]

func (*Stringish) ToLower

func (s *Stringish) ToLower() *Stringish

ToLower lowers all characters of the string

func (*Stringish) ToUpper

func (s *Stringish) ToUpper() *Stringish

ToUpper lowers all characters of the string

func (*Stringish) TrimPrefix

func (s *Stringish) TrimPrefix(prefix string) *Stringish

TrimPrefix trims prefix from the start of the string

func (*Stringish) TrimPrefixSpaces

func (s *Stringish) TrimPrefixSpaces() *Stringish

TrimPrefixSpaces trims space characters from the start of the string

func (*Stringish) TrimSpaces

func (s *Stringish) TrimSpaces() *Stringish

TrimSpaces trims space characters from both sides of the string

func (*Stringish) TrimSuffix

func (s *Stringish) TrimSuffix(suffix string) *Stringish

TrimSuffix trims suffix from the end of the string

func (*Stringish) TrimSuffixSpaces

func (s *Stringish) TrimSuffixSpaces() *Stringish

TrimSuffixSpaces trims space characters from the end of the string

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL