Skip to content

jasonjoo2010/enhanced-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

enhanced-utils

Useful utilities collection.

Concurrent

Distributed lock

It provides interface definition and memory(mock) and redis implementations.

mutex_lock := distlock.NewMutex("project-namespace", 60*time.Second, redis.New([]string{"127.0.0.1:6379"}))

reentry_lock := distlock.NewReentry("project-namespace", 60*time.Second, redis.New([]string{"127.0.0.1:6379"}))

Storage Supported for Lock

  • Mock(memory)
  • Redis
  • Etcdv2
  • Etcdv3
  • Zookeeper
  • Database

String

Convertion

strutils.ToUnderscore("AppleWatch") -> "apple_watch"
strutils.ToCamel("apple_watch") -> "appleWatch"

Random

strutils.RandNumbers(10) -> "0001234567"
strutils.RandString(4) -> "aZb0"
strutils.RandLowCased(4) -> "aaz0"
strutils.RandHash(4) -> "03a0"
strutils.RandPrintable(4) -> "03~0"

Validation

strutils.IsURL("http://www.google.com") -> true
strutils.IsEmail("jack@google.com") -> true

About

String utils, distributed lock, etc

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages