str

package module
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2019 License: MIT Imports: 6 Imported by: 5

README

str GoDoc Go Report Card Commitizen friendly Travis CI

by ddspog

Package str represents a string production line.

License

You are free to copy, modify and distribute str package with attribution under the terms of the MIT license. See the LICENSE file for details.

Installation

Install str package with:

go get github.com/ddspog/str

How to use

This package represents a string production line.

This is made with the interfaces in this package Chainer, Splitter and Collecter. Each are created using srt.New as starting point, this function will convert via fmt.Sprintf, a string to Chainer. And then various operations can be performed on it.

Each object have the ability to put its output as a string, as an error and printed onto desired io.Writer.

The package can be used like this:

feat := "The_fire_Blaze"
s := str.New(feat).Split("_").String() // "ThefireBlaze"

Performance

This package is slower than usual solutions. Because it makes lots of conversion, and the use of fmt package itself, that have some performance problems.

This is due to the objective of this package: to be a clearer tool to operates on strings.

Testing

This package has tests covering all code on it. Further additions to code should try to follow this.

Contribution

This package has some objectives from now:

  • Incorporate all operations on strings package.
  • Incorporate any new ideas about possible improvements.

Any interest in help is much appreciated.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fmt added in v0.4.0

func Fmt(formatter interface{}, args ...interface{}) (s string)

Fmt creates the Chainer using fmt.Sprintf and already returns the string value.

Types

type Chainer

type Chainer interface {
	Printer
	Split(string) Splitter
	SplitN(string, int) Splitter
}

Chainer it's a string factory. It will mount strings through various methods, and then outputted in desired form.

func New

func New(s interface{}, args ...interface{}) (c Chainer)

New creates the Chainer using fmt.Sprintf to ensures string formatting.

type Collecter added in v0.4.0

type Collecter interface {
	Printer
	Array() [][]string
	AnomArray() [][]interface{}
	FmtAll(string, ...interface{}) Splitter
	JoinAll(...string) Splitter
}

Collecter it's an array of splitted factory. It will mount sets of splitted through various methods, and then outputted in desired form.

func Collect added in v0.4.0

func Collect(set interface{}) (c Collecter)

Collect creates the Collecter converting any value received to an array of string arrays.

type Printer

type Printer interface {
	fmt.Stringer
	Error() error
	Print(...io.Writer) (int, error)
}

Printer represents a string factory with the ability to serve it on different outputs.

type Splitter

type Splitter interface {
	Printer
	Array() []string
	AnomArray() []interface{}
	Join(...string) Chainer
}

Splitter it's a string array factory. It will mount strings arrays through various methods, and then outputted in desired form.

func With added in v0.4.0

func With(arr []string) (s Splitter)

With will take an string array and turn into a Splitter.

Jump to

Keyboard shortcuts

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