From 7a6cec96c2747f086420f467517ab20530a0fff2 Mon Sep 17 00:00:00 2001 From: Roshan Ranabhat Date: Sun, 5 Apr 2020 18:55:08 +0545 Subject: [PATCH] Code cleanup --- example/main.go | 34 +++++++++++++++++----------------- helper.go | 2 +- message.go | 6 +++++- stringy.go | 2 +- stringy_test.go | 2 +- 5 files changed, 25 insertions(+), 21 deletions(-) diff --git a/example/main.go b/example/main.go index 82a11db..44ff0a1 100644 --- a/example/main.go +++ b/example/main.go @@ -2,61 +2,61 @@ package main import ( "fmt" - . "github.com/gobeam/Stringy" + stringy "github.com/gobeam/Stringy" ) func main() { - strBetween := New("HelloMyName") + strBetween := stringy.New("HelloMyName") fmt.Println(strBetween.Between("hello", "name").ToUpper()) - 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, "...")) - 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")) - 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")) - 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()) fmt.Println(snakeCase.SnakeCase("?", "").ToUpper()) fmt.Println(snakeCase.SnakeCase("?", "").ToLower()) - 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("?", "", "#", "")) - 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()) - contains := New("hello mam how are you??") + contains := stringy.New("hello mam how are you??") fmt.Println(contains.ContainsAll("mams", "?")) - lines := New("fòô\r\nbàř\nyolo123") + lines := stringy.New("fòô\r\nbàř\nyolo123") fmt.Println(lines.Lines()) - reverse := New("This is only test") + reverse := stringy.New("This is only test") fmt.Println(reverse.Reverse()) - pad := New("Roshan") + pad := stringy.New("Roshan") fmt.Println(pad.Pad(10, "0", "both")) fmt.Println(pad.Pad(10, "0", "left")) fmt.Println(pad.Pad(10, "0", "right")) - shuffleString := New("roshan") + shuffleString := stringy.New("roshan") fmt.Println(shuffleString.Shuffle()) - cleanString := New("special@#remove%%%%") + cleanString := stringy.New("special@#remove%%%%") fmt.Println(cleanString.RemoveSpecialCharacter()) - boolString := New("off") + boolString := stringy.New("off") fmt.Println(boolString.Boolean()) - surroundStr := New("__") + surroundStr := stringy.New("__") fmt.Println(surroundStr.Surround("-")) - str := New("hello__man how-Are you??") + str := stringy.New("hello__man how-Are you??") result := str.CamelCase("?", "") fmt.Println(result) // HelloManHowAreYou diff --git a/helper.go b/helper.go index 24c3c8a..991b255 100644 --- a/helper.go +++ b/helper.go @@ -1,4 +1,4 @@ -package string_manipulation +package stringy import ( "errors" diff --git a/message.go b/message.go index 90fb6a0..da20b62 100644 --- a/message.go +++ b/message.go @@ -1,5 +1,6 @@ -package string_manipulation +package stringy +// const below are used in packages const ( First = "first" Last = "last" @@ -11,5 +12,8 @@ const ( ReplaceCapital = "$1 $2" ) +// False is slice of array for false logical representation in string var False = []string{"off", "no", "0", "false"} + +// True is slice of array for true logical representation in string var True = []string{"on", "yes", "1", "True"} diff --git a/stringy.go b/stringy.go index a696542..102d498 100644 --- a/stringy.go +++ b/stringy.go @@ -1,4 +1,4 @@ -package string_manipulation +package stringy import ( "errors" diff --git a/stringy_test.go b/stringy_test.go index 156e336..1ea5c39 100644 --- a/stringy_test.go +++ b/stringy_test.go @@ -1,4 +1,4 @@ -package string_manipulation +package stringy import ( "testing"