From 324f6eca6edf4a212bae1956abf736cacdba50af Mon Sep 17 00:00:00 2001 From: Roshan Ranabhat Date: Fri, 17 Jul 2020 14:17:40 +0545 Subject: [PATCH] Package name renamed to lowercase --- .travis.yml | 2 +- README.md | 62 ++++++++++++++++++++++++------------------------- example/main.go | 2 +- go.mod | 4 ++-- 4 files changed, 35 insertions(+), 35 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0d8676a..b654b77 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: go sudo: false -go_import_path: github.com/gobeam/Stringy +go_import_path: github.com/gobeam/stringy go: - 1.13 diff --git a/README.md b/README.md index 4b479c5..8653c80 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # 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] -[![Coverage Status](https://coveralls.io/repos/github/gobeam/Stringy/badge.svg)](https://coveralls.io/github/gobeam/Stringy) +[![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) 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 ( "fmt" - . "github.com/gobeam/Stringy" + "github.com/gobeam/stringy" ) func main() { - str := New("hello__man how-Are you??") + str := stringy.New("hello__man how-Are you??") result := str.CamelCase("?", "") fmt.Println(result) // HelloManHowAreYou @@ -83,13 +83,13 @@ func main() { ## Installation ``` bash -$ go get -u -v github.com/gobeam/Stringy +$ go get -u -v github.com/gobeam/stringy ``` or with dep ``` 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. ```go - strBetween := New("HelloMyName") + strBetween := stringy.New("HelloMyName") 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. ```go - boolString := New("off") + boolString := stringy.New("off") 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. ```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 ``` 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 - 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?## ``` @@ -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. ```go - contains := New("hello mam how are you??") + contains := stringy.New("hello mam how are you??") 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. ```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()) ``` 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. ```go - str := New("hello__man how-Are you??") + str := stringy.New("hello__man how-Are you??") kebabStr := str.KebabCase("?","") fmt.Println(kebabStr.ToUpper()) // 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 ```go - contains := New("Hello roshan") + contains := stringy.New("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 ```go - lines := New("fòô\r\nbàř\nyolo123") + lines := stringy.New("fòô\r\nbàř\nyolo123") 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 ```go - pad := New("Roshan") + pad := stringy.New("Roshan") fmt.Println(pad.Pad(0, "0", "both")) // 00Roshan00 fmt.Println(pad.Pad(0, "0", "left")) // 0000Roshan 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 ```go - cleanString := New("special@#remove%%%%") + cleanString := stringy.New("special@#remove%%%%") 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. ```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. ``` @@ -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 ```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. ``` @@ -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. ```go - reverse := New("This is only test") + reverse := stringy.New("This is only test") 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. ```go - shuffleString := New("roshan") + shuffleString := stringy.New("roshan") 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. ```go - surroundStr := New("__") + surroundStr := stringy.New("__") 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. ```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("?", "").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. ```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... ``` @@ -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. ```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 ``` @@ -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. ```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 ``` @@ -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. ```go - contains := New("hello roshan") + contains := stringy.New("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. -[Build-Status-Url]: https://travis-ci.org/gobeam/Stringy -[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-image]: https://godoc.org/github.com/gobeam/Stringy?status.svg +[Build-Status-Url]: https://travis-ci.org/gobeam/stringy +[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-image]: https://godoc.org/github.com/gobeam/stringy?status.svg diff --git a/example/main.go b/example/main.go index 38705dd..9510def 100644 --- a/example/main.go +++ b/example/main.go @@ -2,7 +2,7 @@ package main import ( "fmt" - stringy "github.com/gobeam/Stringy" + "github.com/gobeam/stringy" ) func main() { diff --git a/go.mod b/go.mod index 72ad9d5..e2b1e2c 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ -module github.com/gobeam/Stringy +module github.com/gobeam/stringy -go 1.13 +go 1.14