Package name renamed to lowercase

This commit is contained in:
Roshan Ranabhat 2020-07-17 14:17:40 +05:45
parent 145024d546
commit 324f6eca6e
4 changed files with 35 additions and 35 deletions

View File

@ -1,6 +1,6 @@
language: go language: go
sudo: false sudo: false
go_import_path: github.com/gobeam/Stringy go_import_path: github.com/gobeam/stringy
go: go:
- 1.13 - 1.13

View File

@ -1,6 +1,6 @@
# Golang String manipulation helper package # Golang String manipulation helper package
[![Build][Build-Status-Image]][Build-Status-Url] [![Go Report Card](https://goreportcard.com/badge/github.com/gobeam/Stringy?branch=master&kill_cache=1)](https://goreportcard.com/report/github.com/gobeam/Stringy) [![GoDoc][godoc-image]][godoc-url] [![Build][Build-Status-Image]][Build-Status-Url] [![Go Report Card](https://goreportcard.com/badge/github.com/gobeam/stringy?branch=master&kill_cache=1)](https://goreportcard.com/report/github.com/gobeam/Stringy) [![GoDoc][godoc-image]][godoc-url]
[![Coverage Status](https://coveralls.io/repos/github/gobeam/Stringy/badge.svg)](https://coveralls.io/github/gobeam/Stringy) [![Coverage Status](https://coveralls.io/repos/github/gobeam/stringy/badge.svg)](https://coveralls.io/github/gobeam/stringy)
Convert string to camel case, snake case, kebab case / slugify, custom delimiter, pad string, tease string and many other functionality with help of by Stringy package. You can convert camelcase to snakecase or kebabcase, or snakecase to camelcase and kebabcase and vice versa. This package was inspired from PHP [danielstjules/Stringy](https://github.com/danielstjules/Stringy). Convert string to camel case, snake case, kebab case / slugify, custom delimiter, pad string, tease string and many other functionality with help of by Stringy package. You can convert camelcase to snakecase or kebabcase, or snakecase to camelcase and kebabcase and vice versa. This package was inspired from PHP [danielstjules/Stringy](https://github.com/danielstjules/Stringy).
@ -64,11 +64,11 @@ package main
import ( import (
"fmt" "fmt"
. "github.com/gobeam/Stringy" "github.com/gobeam/stringy"
) )
func main() { func main() {
str := New("hello__man how-Are you??") str := stringy.New("hello__man how-Are you??")
result := str.CamelCase("?", "") result := str.CamelCase("?", "")
fmt.Println(result) // HelloManHowAreYou fmt.Println(result) // HelloManHowAreYou
@ -83,13 +83,13 @@ func main() {
## Installation ## Installation
``` bash ``` bash
$ go get -u -v github.com/gobeam/Stringy $ go get -u -v github.com/gobeam/stringy
``` ```
or with dep or with dep
``` bash ``` bash
$ dep ensure -add github.com/gobeam/Stringy $ dep ensure -add github.com/gobeam/stringy
``` ```
@ -100,7 +100,7 @@ $ dep ensure -add github.com/gobeam/Stringy
Between takes two string params start and end which and returns value which is in middle of start and end part of input. You can chain to upper which with make result all uppercase or ToLower which will make result all lower case or Get which will return result as it is. Between takes two string params start and end which and returns value which is in middle of start and end part of input. You can chain to upper which with make result all uppercase or ToLower which will make result all lower case or Get which will return result as it is.
```go ```go
strBetween := New("HelloMyName") strBetween := stringy.New("HelloMyName")
fmt.Println(strBetween.Between("hello", "name").ToUpper()) // MY fmt.Println(strBetween.Between("hello", "name").ToUpper()) // MY
``` ```
@ -109,7 +109,7 @@ Between takes two string params start and end which and returns value which is i
Boolean func returns boolean value of string value like on, off, 0, 1, yes, no returns boolean value of string input. You can chain this function on other function which returns implemented StringManipulation interface. Boolean func returns boolean value of string value like on, off, 0, 1, yes, no returns boolean value of string input. You can chain this function on other function which returns implemented StringManipulation interface.
```go ```go
boolString := New("off") boolString := stringy.New("off")
fmt.Println(boolString.Boolean()) // false fmt.Println(boolString.Boolean()) // false
``` ```
@ -118,13 +118,13 @@ Boolean func returns boolean value of string value like on, off, 0, 1, yes, no r
CamelCase is variadic function which takes one Param rule i.e slice of strings and it returns input type string in camel case form and rule helps to omit character you want to omit from string. By default special characters like "_", "-","."," " are treated like word separator and treated accordingly by default and you dont have to worry about it. CamelCase is variadic function which takes one Param rule i.e slice of strings and it returns input type string in camel case form and rule helps to omit character you want to omit from string. By default special characters like "_", "-","."," " are treated like word separator and treated accordingly by default and you dont have to worry about it.
```go ```go
camelCase := New("ThisIsOne___messed up string. Can we Really camel-case It ?##") camelCase := stringy.New("ThisIsOne___messed up string. Can we Really camel-case It ?##")
fmt.Println(camelCase.CamelCase("?", "", "#", "")) // ThisIsOneMessedUpStringCanWeReallyCamelCaseIt fmt.Println(camelCase.CamelCase("?", "", "#", "")) // ThisIsOneMessedUpStringCanWeReallyCamelCaseIt
``` ```
look how it omitted ?## from string. If you dont want to omit anything and since it returns plain strings and you cant actually cap all or lower case all camelcase string its not required. look how it omitted ?## from string. If you dont want to omit anything and since it returns plain strings and you cant actually cap all or lower case all camelcase string its not required.
```go ```go
camelCase := New("ThisIsOne___messed up string. Can we Really camel-case It ?##") camelCase := stringy.New("ThisIsOne___messed up string. Can we Really camel-case It ?##")
fmt.Println(camelCase.CamelCase()) // ThisIsOneMessedUpStringCanWeReallyCamelCaseIt?## fmt.Println(camelCase.CamelCase()) // ThisIsOneMessedUpStringCanWeReallyCamelCaseIt?##
``` ```
@ -133,7 +133,7 @@ look how it omitted ?## from string. If you dont want to omit anything and since
ContainsAll is variadic function which takes slice of strings as param and checks if they are present in input and returns boolean value accordingly. ContainsAll is variadic function which takes slice of strings as param and checks if they are present in input and returns boolean value accordingly.
```go ```go
contains := New("hello mam how are you??") contains := stringy.New("hello mam how are you??")
fmt.Println(contains.ContainsAll("mam", "?")) // true fmt.Println(contains.ContainsAll("mam", "?")) // true
``` ```
@ -142,7 +142,7 @@ ContainsAll is variadic function which takes slice of strings as param and check
Delimited is variadic function that takes two params delimiter and slice of strings named rule. It joins the string by passed delimeter. Rule param helps to omit character you want to omit from string. By default special characters like "_", "-","."," " are treated like word separator and treated accordingly by default and you dont have to worry about it. If you don't want to omit any character pass empty string. Delimited is variadic function that takes two params delimiter and slice of strings named rule. It joins the string by passed delimeter. Rule param helps to omit character you want to omit from string. By default special characters like "_", "-","."," " are treated like word separator and treated accordingly by default and you dont have to worry about it. If you don't want to omit any character pass empty string.
```go ```go
delimiterString := New("ThisIsOne___messed up string. Can we Really delimeter-case It?") delimiterString := stringy.New("ThisIsOne___messed up string. Can we Really delimeter-case It?")
fmt.Println(delimiterString.Delimited("?").Get()) fmt.Println(delimiterString.Delimited("?").Get())
``` ```
You can chain to upper which with make result all uppercase or ToLower which will make result all lower case or Get which will return result as it is. You can chain to upper which with make result all uppercase or ToLower which will make result all lower case or Get which will return result as it is.
@ -169,7 +169,7 @@ Get simply returns result and can be chained on function which returns StringMan
KebabCase/slugify is variadic function that takes one Param slice of strings named rule and it returns passed string in kebab case or slugify form. Rule param helps to omit character you want to omit from string. By default special characters like "_", "-","."," " are treated like word separator and treated accordingly by default and you don't have to worry about it. If you don't want to omit any character pass nothing. KebabCase/slugify is variadic function that takes one Param slice of strings named rule and it returns passed string in kebab case or slugify form. Rule param helps to omit character you want to omit from string. By default special characters like "_", "-","."," " are treated like word separator and treated accordingly by default and you don't have to worry about it. If you don't want to omit any character pass nothing.
```go ```go
str := New("hello__man how-Are you??") str := stringy.New("hello__man how-Are you??")
kebabStr := str.KebabCase("?","") kebabStr := str.KebabCase("?","")
fmt.Println(kebabStr.ToUpper()) // HELLO-MAN-HOW-ARE-YOU fmt.Println(kebabStr.ToUpper()) // HELLO-MAN-HOW-ARE-YOU
fmt.Println(kebabStr.Get()) // hello-man-how-Are-you fmt.Println(kebabStr.Get()) // hello-man-how-Are-you
@ -193,7 +193,7 @@ Last returns last n characters from provided input. It removes all spaces in str
LcFirst simply returns result by lower casing first letter of string and it can be chained on function which return StringManipulation interface LcFirst simply returns result by lower casing first letter of string and it can be chained on function which return StringManipulation interface
```go ```go
contains := New("Hello roshan") contains := stringy.New("Hello roshan")
fmt.Println(contains.LcFirst()) // hello roshan fmt.Println(contains.LcFirst()) // hello roshan
``` ```
@ -203,7 +203,7 @@ LcFirst simply returns result by lower casing first letter of string and it can
Lines returns slice of strings by removing white space characters Lines returns slice of strings by removing white space characters
```go ```go
lines := New("fòô\r\nbàř\nyolo123") lines := stringy.New("fòô\r\nbàř\nyolo123")
fmt.Println(lines.Lines()) // [fòô bàř yolo123] fmt.Println(lines.Lines()) // [fòô bàř yolo123]
``` ```
@ -213,7 +213,7 @@ Lines returns slice of strings by removing white space characters
Pad takes three param length i.e total length to be after padding, with i.e what to pad with and pad type which can be ("both" or "left" or "right") it return string after padding upto length by with param and on padType type it can be chained on function which return StringManipulation interface Pad takes three param length i.e total length to be after padding, with i.e what to pad with and pad type which can be ("both" or "left" or "right") it return string after padding upto length by with param and on padType type it can be chained on function which return StringManipulation interface
```go ```go
pad := New("Roshan") pad := stringy.New("Roshan")
fmt.Println(pad.Pad(0, "0", "both")) // 00Roshan00 fmt.Println(pad.Pad(0, "0", "both")) // 00Roshan00
fmt.Println(pad.Pad(0, "0", "left")) // 0000Roshan fmt.Println(pad.Pad(0, "0", "left")) // 0000Roshan
fmt.Println(pad.Pad(0, "0", "right")) // Roshan0000 fmt.Println(pad.Pad(0, "0", "right")) // Roshan0000
@ -225,7 +225,7 @@ Pad takes three param length i.e total length to be after padding, with i.e wha
RemoveSpecialCharacter removes all special characters and returns the string nit can be chained on function which return StringManipulation interface RemoveSpecialCharacter removes all special characters and returns the string nit can be chained on function which return StringManipulation interface
```go ```go
cleanString := New("special@#remove%%%%") cleanString := stringy.New("special@#remove%%%%")
fmt.Println(cleanString.RemoveSpecialCharacter()) // specialremove fmt.Println(cleanString.RemoveSpecialCharacter()) // specialremove
``` ```
@ -235,7 +235,7 @@ RemoveSpecialCharacter removes all special characters and returns the string nit
ReplaceFirst takes two param search and replace. It returns string by searching search sub string and replacing it with replace substring on first occurrence it can be chained on function which return StringManipulation interface. ReplaceFirst takes two param search and replace. It returns string by searching search sub string and replacing it with replace substring on first occurrence it can be chained on function which return StringManipulation interface.
```go ```go
replaceFirst := New("Hello My name is Roshan and his name is Alis.") replaceFirst := stringy.New("Hello My name is Roshan and his name is Alis.")
fmt.Println(replaceFirst.ReplaceFirst("name", "nombre")) // Hello My nombre is Roshan and his name is Alis. fmt.Println(replaceFirst.ReplaceFirst("name", "nombre")) // Hello My nombre is Roshan and his name is Alis.
``` ```
@ -245,7 +245,7 @@ ReplaceFirst takes two param search and replace. It returns string by searching
ReplaceLast takes two param search and replace it return string by searching search sub string and replacing it with replace substring on last occurrence it can be chained on function which return StringManipulation interface ReplaceLast takes two param search and replace it return string by searching search sub string and replacing it with replace substring on last occurrence it can be chained on function which return StringManipulation interface
```go ```go
replaceLast := New("Hello My name is Roshan and his name is Alis.") replaceLast := stringy.New("Hello My name is Roshan and his name is Alis.")
fmt.Println(replaceLast.ReplaceLast("name", "nombre")) // Hello My name is Roshan and his nombre is Alis. fmt.Println(replaceLast.ReplaceLast("name", "nombre")) // Hello My name is Roshan and his nombre is Alis.
``` ```
@ -255,7 +255,7 @@ ReplaceLast takes two param search and replace it return string by searching sea
Reverse function reverses the passed strings it can be chained on function which return StringManipulation interface. Reverse function reverses the passed strings it can be chained on function which return StringManipulation interface.
```go ```go
reverse := New("This is only test") reverse := stringy.New("This is only test")
fmt.Println(reverse.Reverse()) // tset ylno si sihT fmt.Println(reverse.Reverse()) // tset ylno si sihT
``` ```
@ -265,7 +265,7 @@ Reverse function reverses the passed strings it can be chained on function which
Shuffle shuffles the given string randomly it can be chained on function which return StringManipulation interface. Shuffle shuffles the given string randomly it can be chained on function which return StringManipulation interface.
```go ```go
shuffleString := New("roshan") shuffleString := stringy.New("roshan")
fmt.Println(shuffleString.Shuffle()) // nhasro fmt.Println(shuffleString.Shuffle()) // nhasro
``` ```
@ -275,7 +275,7 @@ Shuffle shuffles the given string randomly it can be chained on function which r
Surround takes one param with which is used to surround user input and it can be chained on function which return StringManipulation interface. Surround takes one param with which is used to surround user input and it can be chained on function which return StringManipulation interface.
```go ```go
surroundStr := New("__") surroundStr := stringy.New("__")
fmt.Println(surroundStr.Surround("-")) // -__- fmt.Println(surroundStr.Surround("-")) // -__-
``` ```
@ -285,7 +285,7 @@ Surround takes one param with which is used to surround user input and it can be
SnakeCase is variadic function that takes one Param slice of strings named rule and it returns passed string in snake case form. Rule param helps to omit character you want to omit from string. By default special characters like "_", "-","."," " are treated like word separator and treated accordingly by default and you don't have to worry about it. If you don't want to omit any character pass nothing. SnakeCase is variadic function that takes one Param slice of strings named rule and it returns passed string in snake case form. Rule param helps to omit character you want to omit from string. By default special characters like "_", "-","."," " are treated like word separator and treated accordingly by default and you don't have to worry about it. If you don't want to omit any character pass nothing.
```go ```go
snakeCase := New("ThisIsOne___messed up string. Can we Really Snake Case It?") snakeCase := stringy.New("ThisIsOne___messed up string. Can we Really Snake Case It?")
fmt.Println(snakeCase.SnakeCase("?", "").Get()) // This_Is_One_messed_up_string_Can_we_Really_Snake_Case_It fmt.Println(snakeCase.SnakeCase("?", "").Get()) // This_Is_One_messed_up_string_Can_we_Really_Snake_Case_It
fmt.Println(snakeCase.SnakeCase("?", "").ToUpper()) // THIS_IS_ONE_MESSED_UP_STRING_CAN_WE_REALLY_SNAKE_CASE_IT fmt.Println(snakeCase.SnakeCase("?", "").ToUpper()) // THIS_IS_ONE_MESSED_UP_STRING_CAN_WE_REALLY_SNAKE_CASE_IT
``` ```
@ -297,7 +297,7 @@ You can chain to upper which with make result all uppercase or ToLower which wil
Tease takes two params length and indicator and it shortens given string on passed length and adds indicator on end it can be chained on function which return StringManipulation interface. Tease takes two params length and indicator and it shortens given string on passed length and adds indicator on end it can be chained on function which return StringManipulation interface.
```go ```go
teaseString := New("Hello My name is Roshan. I am full stack developer") teaseString := stringy.New("Hello My name is Roshan. I am full stack developer")
fmt.Println(teaseString.Tease(20, "...")) // Hello My name is Ros... fmt.Println(teaseString.Tease(20, "...")) // Hello My name is Ros...
``` ```
@ -307,7 +307,7 @@ Tease takes two params length and indicator and it shortens given string on pass
ToLower makes all string of user input to lowercase and it can be chained on function which return StringManipulation interface. ToLower makes all string of user input to lowercase and it can be chained on function which return StringManipulation interface.
```go ```go
snakeCase := New("ThisIsOne___messed up string. Can we Really Snake Case It?") snakeCase := stringy.New("ThisIsOne___messed up string. Can we Really Snake Case It?")
fmt.Println(snakeCase.SnakeCase("?", "").ToLower()) // this_is_one_messed_up_string_can_we_really_snake_case_it fmt.Println(snakeCase.SnakeCase("?", "").ToLower()) // this_is_one_messed_up_string_can_we_really_snake_case_it
``` ```
@ -317,7 +317,7 @@ ToLower makes all string of user input to lowercase and it can be chained on fun
ToUpper makes all string of user input to uppercase and it can be chained on function which return StringManipulation interface. ToUpper makes all string of user input to uppercase and it can be chained on function which return StringManipulation interface.
```go ```go
snakeCase := New("ThisIsOne___messed up string. Can we Really Snake Case It?") snakeCase := stringy.New("ThisIsOne___messed up string. Can we Really Snake Case It?")
fmt.Println(snakeCase.SnakeCase("?", "").ToUpper()) // THIS_IS_ONE_MESSED_UP_STRING_CAN_WE_REALLY_SNAKE_CASE_IT fmt.Println(snakeCase.SnakeCase("?", "").ToUpper()) // THIS_IS_ONE_MESSED_UP_STRING_CAN_WE_REALLY_SNAKE_CASE_IT
``` ```
@ -327,7 +327,7 @@ ToUpper makes all string of user input to uppercase and it can be chained on fun
LcFirst simply returns result by lower casing first letter of string and it can be chained on function which return StringManipulation interface. LcFirst simply returns result by lower casing first letter of string and it can be chained on function which return StringManipulation interface.
```go ```go
contains := New("hello roshan") contains := stringy.New("hello roshan")
fmt.Println(contains.UcFirst()) // Hello roshan fmt.Println(contains.UcFirst()) // Hello roshan
``` ```
@ -350,8 +350,8 @@ Please make sure to update tests as appropriate.
Released under the MIT License - see `LICENSE.txt` for details. Released under the MIT License - see `LICENSE.txt` for details.
[Build-Status-Url]: https://travis-ci.org/gobeam/Stringy [Build-Status-Url]: https://travis-ci.org/gobeam/stringy
[Build-Status-Image]: https://travis-ci.org/gobeam/Stringy.svg?branch=master [Build-Status-Image]: https://travis-ci.org/gobeam/stringy.svg?branch=master
[godoc-url]: https://pkg.go.dev/github.com/gobeam/Stringy?tab=doc [godoc-url]: https://pkg.go.dev/github.com/gobeam/stringy?tab=doc
[godoc-image]: https://godoc.org/github.com/gobeam/Stringy?status.svg [godoc-image]: https://godoc.org/github.com/gobeam/stringy?status.svg

View File

@ -2,7 +2,7 @@ package main
import ( import (
"fmt" "fmt"
stringy "github.com/gobeam/Stringy" "github.com/gobeam/stringy"
) )
func main() { func main() {

4
go.mod
View File

@ -1,3 +1,3 @@
module github.com/gobeam/Stringy module github.com/gobeam/stringy
go 1.13 go 1.14