Popularity
5.8
Stable
Activity
0.0
Stable
287
14
37
Programming language: Go
License: MIT License
Tags:
Utilities
util alternatives and similar packages
Based on the "Utilities" category.
Alternatively, view util alternatives based on common mentions on social networks and blogs.
-
项目文档
🚀Vite+Vue3+Gin的开发基础平台,支持TS和JS混用。它集成了JWT鉴权、权限管理、动态路由、显隐可控组件、分页封装、多点登录拦截、资源权限、上传下载、代码生成器【可AI辅助】、表单生成器和可配置的导入导出等开发必备功能。 -
excelize
Go language library for reading and writing Microsoft Excel™ (XLAM / XLSM / XLSX / XLTM / XLTX) spreadsheets -
Kopia
Cross-platform backup tool for Windows, macOS & Linux with fast, incremental backups, client-side end-to-end encryption, compression and data deduplication. CLI and GUI included. -
goreporter
A Golang tool that does static analysis, unit testing, code review and generate code quality report. -
create-go-app
✨ A complete and self-contained solution for developers of any qualification to create a production-ready project with backend (Go), frontend (JavaScript, TypeScript) and deploy automation (Ansible, Docker) by running only one CLI command. -
EaseProbe
A simple, standalone, and lightweight tool that can do health/status checking, written in Go. -
filetype
Fast, dependency-free Go package to infer binary file types based on the magic numbers header signature -
boilr
:zap: boilerplate template manager that generates files or directories from template repositories -
beaver
💨 A real time messaging system to build a scalable in-app notifications, multiplayer games, chat apps in web and mobile apps. -
go-underscore
Helpfully Functional Go - A useful collection of Go utilities. Designed for programmer happiness.
InfluxDB - Purpose built for real-time analytics at any scale.
InfluxDB Platform is powered by columnar analytics, optimized for cost-efficient storage, and built with open data standards.
Promo
www.influxdata.com
Do you think we are missing an alternative of util or a related project?
Popular Comparisons
README
util
A group of generic useful utility functions
Dependencies
parallelizer
github.com/shomali11/parallelizer
Examples
Concurrency
package main
import (
"github.com/shomali11/util/xconcurrency"
"time"
"fmt"
)
func main() {
func1 := func() {
for char := 'a'; char < 'a' + 3; char++ {
fmt.Printf("%c ", char)
}
}
func2 := func() {
for number := 1; number < 4; number++ {
fmt.Printf("%d ", number)
}
}
xconcurrency.Parallelize(func1, func2) // a 1 b 2 c 3
xconcurrency.ParallelizeTimeout(time.Minute, func1, func2) // a 1 b 2 c 3
}
Hashes
package main
import (
"github.com/shomali11/util/xhashes"
"fmt"
)
func main() {
fmt.Println(xhashes.FNV32("Raed Shomali")) // 424383802
fmt.Println(xhashes.FNV32a("Raed Shomali")) // 3711360776
fmt.Println(xhashes.FNV64("Raed Shomali")) // 13852322269024953050
fmt.Println(xhashes.FNV64a("Raed Shomali")) // 17869303103005344072
fmt.Println(xhashes.MD5("Raed Shomali")) // c313bc3b48fcfed9abc733429665b105
fmt.Println(xhashes.SHA1("Raed Shomali")) // e0d66f6f09de72942e83289cc994b3c721ab34c5
fmt.Println(xhashes.SHA256("Raed Shomali")) // 75894b9be21065a833e57bfe4440b375fc216f120a965243c9be8b2dc36709c2
fmt.Println(xhashes.SHA512("Raed Shomali")) // 406e8d495140187a8b09893c30d054cf385ad7359855db0d2e0386c7189ac1c4667a4816d1b63a19f3d8ccdcbace7861ec4cc6ff5e2a1659c8f4360bda699b42
}
Compressions
package main
import (
"github.com/shomali11/util/xcompressions"
"fmt"
)
func main() {
fmt.Println(xcompressions.Compress([]byte("Raed Shomali")))
}
Encodings
package main
import (
"github.com/shomali11/util/xencodings"
"fmt"
)
func main() {
fmt.Println(xencodings.Base32Encode([]byte("Raed Shomali")))
fmt.Println(xencodings.Base64Encode([]byte("Raed Shomali")))
}
Strings
package main
import (
"github.com/shomali11/util/xstrings"
"fmt"
)
func main() {
fmt.Println(xstrings.IsEmpty("")) // true
fmt.Println(xstrings.IsEmpty("text")) // false
fmt.Println(xstrings.IsEmpty(" ")) // false
fmt.Println(xstrings.IsNotEmpty("")) // false
fmt.Println(xstrings.IsNotEmpty("text")) // true
fmt.Println(xstrings.IsNotEmpty(" ")) // true
fmt.Println(xstrings.IsBlank("")) // true
fmt.Println(xstrings.IsBlank(" ")) // true
fmt.Println(xstrings.IsBlank("text")) // false
fmt.Println(xstrings.IsNotBlank("")) // false
fmt.Println(xstrings.IsNotBlank(" ")) // false
fmt.Println(xstrings.IsNotBlank("text")) // true
fmt.Println(xstrings.Left("", 5)) // " "
fmt.Println(xstrings.Left("X", 5)) // "X "
fmt.Println(xstrings.Left("😎⚽", 4)) // "😎⚽ "
fmt.Println(xstrings.Left("ab\u0301cde", 8)) // "ab́cde "
fmt.Println(xstrings.Right("", 5)) // " "
fmt.Println(xstrings.Right("X", 5)) // " X"
fmt.Println(xstrings.Right("😎⚽", 4)) // " 😎⚽"
fmt.Println(xstrings.Right("ab\u0301cde", 8)) // " ab́cde"
fmt.Println(xstrings.Center("", 5)) // " "
fmt.Println(xstrings.Center("X", 5)) // " X "
fmt.Println(xstrings.Center("😎⚽", 4)) // " 😎⚽ "
fmt.Println(xstrings.Center("ab\u0301cde", 8)) // " ab́cde "
fmt.Println(xstrings.Length("")) // 0
fmt.Println(xstrings.Length("X")) // 1
fmt.Println(xstrings.Length("b\u0301")) // 1
fmt.Println(xstrings.Length("😎⚽")) // 2
fmt.Println(xstrings.Length("Les Mise\u0301rables")) // 14
fmt.Println(xstrings.Length("ab\u0301cde")) // 5
fmt.Println(xstrings.Length("This `\xc5` is an invalid UTF8 character")) // 37
fmt.Println(xstrings.Length("The quick bròwn 狐 jumped over the lazy 犬")) // 40
fmt.Println(xstrings.Reverse("")) // ""
fmt.Println(xstrings.Reverse("X")) // "X"
fmt.Println(xstrings.Reverse("😎⚽")) // "⚽😎"
fmt.Println(xstrings.Reverse("Les Mise\u0301rables")) // "selbare\u0301siM seL"
fmt.Println(xstrings.Reverse("This `\xc5` is an invalid UTF8 character")) // "retcarahc 8FTU dilavni na si `�` sihT"
fmt.Println(xstrings.Reverse("The quick bròwn 狐 jumped over the lazy 犬")) // "犬 yzal eht revo depmuj 狐 nwòrb kciuq ehT"
}
Conditions
package main
import (
"github.com/shomali11/util/xconditions"
"fmt"
)
func main() {
fmt.Println(xconditions.IfThen(1 == 1, "Yes")) // "Yes"
fmt.Println(xconditions.IfThen(1 != 1, "Woo")) // nil
fmt.Println(xconditions.IfThen(1 < 2, "Less")) // "Less"
fmt.Println(xconditions.IfThenElse(1 == 1, "Yes", false)) // "Yes"
fmt.Println(xconditions.IfThenElse(1 != 1, nil, 1)) // 1
fmt.Println(xconditions.IfThenElse(1 < 2, nil, "No")) // nil
fmt.Println(xconditions.DefaultIfNil(nil, nil)) // nil
fmt.Println(xconditions.DefaultIfNil(nil, "")) // ""
fmt.Println(xconditions.DefaultIfNil("A", "B")) // "A"
fmt.Println(xconditions.DefaultIfNil(true, "B")) // true
fmt.Println(xconditions.DefaultIfNil(1, false)) // 1
fmt.Println(xconditions.FirstNonNil(nil, nil)) // nil
fmt.Println(xconditions.FirstNonNil(nil, "")) // ""
fmt.Println(xconditions.FirstNonNil("A", "B")) // "A"
fmt.Println(xconditions.FirstNonNil(true, "B")) // true
fmt.Println(xconditions.FirstNonNil(1, false)) // 1
fmt.Println(xconditions.FirstNonNil(nil, nil, nil, 10)) // 10
fmt.Println(xconditions.FirstNonNil(nil, nil, nil, nil, nil)) // nil
fmt.Println(xconditions.FirstNonNil()) // nil
}
Errors
package main
import (
"github.com/shomali11/util/xerrors"
"fmt"
)
func main() {
fmt.Println(xerrors.DefaultErrorIfNil(nil, "Cool")) // "Cool"
fmt.Println(xerrors.DefaultErrorIfNil(errors.New("Oops"), "Cool")) // "Oops"
}
Manipulations
package main
import (
"github.com/shomali11/util/xmanipulations"
"math/rand"
"time"
"fmt"
)
func main() {
source := rand.NewSource(time.Now().UnixNano())
array := []interface{}{"a", "b", "c"}
xmanipulations.Shuffle(array, source)
fmt.Println(array) // [c b a]
}
Conversions
Return a pretty JSON representation of any interface
package main
import (
"github.com/shomali11/util/xconversions"
"fmt"
)
func main() {
x := map[string]interface{}{"number": 1, "string": "cool", "bool": true, "float": 1.5}
fmt.Println(xconversions.PrettyJson(x))
}
{
"bool": true,
"float": 1.5,
"number": 1,
"string": "cool"
}
Convert any interface to a String
package main
import (
"github.com/shomali11/util/xconversions"
"fmt"
)
func main() {
x := map[string]interface{}{"number": 1, "string": "cool", "bool": true, "float": 1.5}
fmt.Println(xconversions.Stringify(x))
}
{"bool":true,"float":1.5,"number":1,"string":"cool"} <nil>
Convert any string back to its original struct
package main
import (
"github.com/shomali11/util/xconversions"
"fmt"
)
func main() {
x := "{\"bool\":true,\"float\":1.5,\"number\":1,\"string\":\"cool\"}"
var results map[string]interface{}
fmt.Println(xconversions.Structify(x, &results))
fmt.Println(results)
}
<nil>
map[bool:true float:1.5 number:1 string:cool]
*Note that all licence references and agreements mentioned in the util README section above
are relevant to that project's source code only.