Skip to content

Commit

Permalink
♻️ refactor: refactor codebase #2
Browse files Browse the repository at this point in the history
  • Loading branch information
pnguyen215 committed Oct 24, 2024
1 parent 1f3f889 commit bef96b7
Show file tree
Hide file tree
Showing 16 changed files with 93 additions and 94 deletions.
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# unify4go
# unify4g

**unify4go** is a comprehensive Go library designed to enhance productivity by providing a suite of utilities for string manipulation, time handling, type conversions, and more. It aims to facilitate cleaner and more maintainable code.
**unify4g** is a comprehensive Go library designed to enhance productivity by providing a suite of utilities for string manipulation, time handling, type conversions, and more. It aims to facilitate cleaner and more maintainable code.

## Features

- **String Utilities**: Enhance and manipulate strings efficiently.
- **Time Handling**: Simplify date and time operations.
- **Type Conversions**: Convert between various data types effortlessly.
- **Miscellaneous Utilities**: A collection of tools to enhance your Go development experience.

Expand All @@ -20,12 +19,12 @@ To install, you can use the following commands based on your preference:
- For a specific version:

```bash
go get github.com/sivaosorg/unify4go[email protected]
go get github.com/sivaosorg/unify4g[email protected]
```

- For the latest version:
```bash
go get -u github.com/sivaosorg/unify4go.git@latest
go get -u github.com/sivaosorg/unify4g.git@latest
```

### Contributing
Expand All @@ -35,13 +34,13 @@ To contribute to project, follow these steps:
1. Clone the repository:

```bash
git clone --depth 1 https://github.com/sivaosorg/unify4go.git
git clone --depth 1 https://github.com/sivaosorg/unify4g.git
```

2. Navigate to the project directory:

```bash
cd unify4go
cd unify4g
```

3. Prepare the project environment:
Expand Down
2 changes: 1 addition & 1 deletion const.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package unify4go
package unify4g

import (
"regexp"
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/sivaosorg/unify4go
module github.com/sivaosorg/unify4g

go 1.23.1

Expand Down
2 changes: 1 addition & 1 deletion hashmap.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package unify4go
package unify4g

// HashMap is a generic hash map data structure that maps keys of type `K` to values of type `V`.
// `K` and `V` must be comparable types, meaning that they support comparison operators (like == and !=).
Expand Down
2 changes: 1 addition & 1 deletion hashset.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package unify4go
package unify4g

import "fmt"

Expand Down
2 changes: 1 addition & 1 deletion json.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package unify4go
package unify4g

import (
jsonI "github.com/json-iterator/go"
Expand Down
2 changes: 1 addition & 1 deletion normalization.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package unify4go
package unify4g

// normalize_rune takes a rune as input and returns its normalized string representation.
//
Expand Down
2 changes: 1 addition & 1 deletion random.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package unify4go
package unify4g

import (
"math/rand"
Expand Down
2 changes: 1 addition & 1 deletion reflect.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package unify4go
package unify4g

import "reflect"

Expand Down
2 changes: 1 addition & 1 deletion stack.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package unify4go
package unify4g

// Stack is a generic stack data structure that stores elements of type `T`.
// It provides basic stack operations like push, pop, and peek.
Expand Down
14 changes: 7 additions & 7 deletions strings.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package unify4go
package unify4g

import (
"crypto/sha256"
Expand Down Expand Up @@ -783,10 +783,10 @@ func RemoveAccents(s string) string {
//
// Example:
//
// unify4go.Slugify("'We löve Motörhead'") //Output: we-love-motorhead
// unify4g.Slugify("'We löve Motörhead'") //Output: we-love-motorhead
//
// Normalzation is done with unify4go.ReplaceAccents function using a rune replacement map
// You can use the following code for better normalization before unify4go.Slugify()
// Normalzation is done with unify4g.ReplaceAccents function using a rune replacement map
// You can use the following code for better normalization before unify4g.Slugify()
//
// str := "'We löve Motörhead'"
// t := transform.Chain(norm.NFD, runes.Remove(runes.In(unicode.Mn)), norm.NFC)
Expand All @@ -800,7 +800,7 @@ func RemoveAccents(s string) string {
// import "github.com/rainycape/unidecode"
//
// str := unidecode.Unidecode("你好, world!")
// unify4go.Slugify(str) //Output: ni-hao-world
// unify4g.Slugify(str) //Output: ni-hao-world
func Slugify(s string) string {
return SlugifySpecial(s, "-")
}
Expand All @@ -811,7 +811,7 @@ func Slugify(s string) string {
//
// Example:
//
// unify4go.SlugifySpecial("'We löve Motörhead'", "-") //Output: we-love-motorhead
// unify4g.SlugifySpecial("'We löve Motörhead'", "-") //Output: we-love-motorhead
//
// SlugifySpecial doesn't support transliteration. You should use a transliteration
// library before SlugifySpecial like github.com/rainycape/unidecode
Expand All @@ -821,7 +821,7 @@ func Slugify(s string) string {
// import "github.com/rainycape/unidecode"
//
// str := unidecode.Unidecode("你好, world!")
// unify4go.SlugifySpecial(str, "-") //Output: ni-hao-world
// unify4g.SlugifySpecial(str, "-") //Output: ni-hao-world
func SlugifySpecial(str string, delimiter string) string {
str = RemoveAccents(str)
delBytes := []byte(delimiter)
Expand Down
32 changes: 16 additions & 16 deletions test/hashmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ package example_test
import (
"testing"

"github.com/sivaosorg/unify4go"
"github.com/sivaosorg/unify4g"
)

func TestNewHashMap(t *testing.T) {
hashMap := unify4go.NewHashMap[int, string]()
hashMap := unify4g.NewHashMap[int, string]()
if hashMap == nil {
t.Errorf("Hashmap is nil")
return
}
}

func TestPut(t *testing.T) {
hashMap := unify4go.NewHashMap[int, string]()
hashMap := unify4g.NewHashMap[int, string]()
if hashMap == nil {
t.Errorf("Hashmap is nil")
return
Expand All @@ -38,7 +38,7 @@ func TestPut(t *testing.T) {
}

func TestGet(t *testing.T) {
hashMap := unify4go.NewHashMap[int, string]()
hashMap := unify4g.NewHashMap[int, string]()
if hashMap == nil {
t.Errorf("Hashmap is nil")
return
Expand All @@ -57,7 +57,7 @@ func TestGet(t *testing.T) {
}

func TestRemove(t *testing.T) {
hashMap := unify4go.NewHashMap[int, string]()
hashMap := unify4g.NewHashMap[int, string]()
if hashMap == nil {
t.Errorf("Hashmap is nil")
return
Expand All @@ -78,7 +78,7 @@ func TestRemove(t *testing.T) {
}

func TestClear(t *testing.T) {
hashMap := unify4go.NewHashMap[int, string]()
hashMap := unify4g.NewHashMap[int, string]()
if hashMap == nil {
t.Errorf("Hashmap is nil")
return
Expand All @@ -95,7 +95,7 @@ func TestClear(t *testing.T) {
}

func TestKeySet(t *testing.T) {
hashMap := unify4go.NewHashMap[int, string]()
hashMap := unify4g.NewHashMap[int, string]()
if hashMap == nil {
t.Errorf("Hashmap is nil")
return
Expand All @@ -112,7 +112,7 @@ func TestKeySet(t *testing.T) {
}

func BenchmarkHashMapPut100(b *testing.B) {
hashMap := unify4go.NewHashMap[int, string]()
hashMap := unify4g.NewHashMap[int, string]()
b.StopTimer()
b.StartTimer()
for i := 0; i < b.N; i++ {
Expand All @@ -123,7 +123,7 @@ func BenchmarkHashMapPut100(b *testing.B) {
}

func BenchmarkHashMapPut10000(b *testing.B) {
hashMap := unify4go.NewHashMap[int, string]()
hashMap := unify4g.NewHashMap[int, string]()
b.StopTimer()
b.StartTimer()
for i := 0; i < b.N; i++ {
Expand All @@ -134,7 +134,7 @@ func BenchmarkHashMapPut10000(b *testing.B) {
}

func BenchmarkHashMapPut1000000(b *testing.B) {
hashMap := unify4go.NewHashMap[int, string]()
hashMap := unify4g.NewHashMap[int, string]()
b.StopTimer()
b.StartTimer()
for i := 0; i < b.N; i++ {
Expand All @@ -145,7 +145,7 @@ func BenchmarkHashMapPut1000000(b *testing.B) {
}

func BenchmarkHashMapRemove100(b *testing.B) {
hashMap := unify4go.NewHashMap[int, string]()
hashMap := unify4g.NewHashMap[int, string]()

for i := 0; i < b.N; i++ {
b.StopTimer()
Expand All @@ -160,7 +160,7 @@ func BenchmarkHashMapRemove100(b *testing.B) {
}

func BenchmarkHashMapRemove10000(b *testing.B) {
hashMap := unify4go.NewHashMap[int, string]()
hashMap := unify4g.NewHashMap[int, string]()

for i := 0; i < b.N; i++ {
b.StopTimer()
Expand All @@ -175,7 +175,7 @@ func BenchmarkHashMapRemove10000(b *testing.B) {
}

func BenchmarkHashMapRemove1000000(b *testing.B) {
hashMap := unify4go.NewHashMap[int, string]()
hashMap := unify4g.NewHashMap[int, string]()

for i := 0; i < b.N; i++ {
b.StopTimer()
Expand All @@ -190,7 +190,7 @@ func BenchmarkHashMapRemove1000000(b *testing.B) {
}

func BenchmarkHashMapContains100(b *testing.B) {
hashMap := unify4go.NewHashMap[int, string]()
hashMap := unify4g.NewHashMap[int, string]()
for j := 0; j < 100; j++ {
hashMap.Put(j, "test")
}
Expand All @@ -202,7 +202,7 @@ func BenchmarkHashMapContains100(b *testing.B) {
}

func BenchmarkHashMapContains10000(b *testing.B) {
hashMap := unify4go.NewHashMap[int, string]()
hashMap := unify4g.NewHashMap[int, string]()
for j := 0; j < 10000; j++ {
hashMap.Put(j, "test")
}
Expand All @@ -214,7 +214,7 @@ func BenchmarkHashMapContains10000(b *testing.B) {
}

func BenchmarkHashMapContains1000000(b *testing.B) {
hashMap := unify4go.NewHashMap[int, string]()
hashMap := unify4g.NewHashMap[int, string]()
for j := 0; j < 1000000; j++ {
hashMap.Put(j, "test")
}
Expand Down
Loading

0 comments on commit bef96b7

Please sign in to comment.