thinkeridea / go-extend Goto Github PK
View Code? Open in Web Editor NEWgo语言扩展包,收集一些常用的操作函数,辅助更快的完成开发工作,并减少重复代码
Home Page: https://pkg.go.dev/github.com/thinkeridea/go-extend
License: MIT License
go语言扩展包,收集一些常用的操作函数,辅助更快的完成开发工作,并减少重复代码
Home Page: https://pkg.go.dev/github.com/thinkeridea/go-extend
License: MIT License
"10.0.0.0/8",
"169.254.0.0/16",
"172.16.0.0/12",
"172.17.0.0/12",
"172.18.0.0/12",
"172.19.0.0/12",
"172.20.0.0/12",
"172.21.0.0/12",
"172.22.0.0/12",
"172.23.0.0/12",
"172.24.0.0/12",
"172.25.0.0/12",
"172.26.0.0/12",
"172.27.0.0/12",
"172.28.0.0/12",
"172.29.0.0/12",
"172.30.0.0/12",
"172.31.0.0/12",
"192.168.0.0/16",
172.16~31.0.0/12
其掩码地址均为 172.16.0.0/12
存在重复。
使用直接对比ip段前两段数据检查,不使用 network.Contains
判断,在暂时不支持IPV6
的前提下,这种方法更加高效。
使用 utf8.DecodeRuneInString
逐个解析字符,使得比把字符串转为 []rune
运行效率更高,但是这并不是最好的解决方案,我需要一个方法在字符串中计算指定数量字符的索引位置,使得可以高效的利用字符串切片获得高效处理多字节字符的方案。
灵感来自 #5
go的编译基本只能静态编译,这样gpl的传染性导致所有的代码都得开源,
这样其实不利于本库得到更多的使用,
相当多的go库都采用mit license
#16 在性能测试时,对SyncPool
测试时并没有对 Buffer
进行 Reset
操作,导致大量内存分配,测试结果没有参考性。
在完善测试用例后,以下测试结果并没有相较 sync.Pool 有明显优势,且可能对性能产生影响。
goos: darwin
goarch: amd64
pkg: github.com/thinkeridea/go-extend/pool/benchmark
BenchmarkBufferPool
BenchmarkBufferPool-8 943312 1065 ns/op 1 B/op 0 allocs/op
BenchmarkBufferSyncPool
BenchmarkBufferSyncPool-8 1000000 1032 ns/op 0 B/op 0 allocs/op
BenchmarkBufferFixedSizePool
BenchmarkBufferFixedSizePool-8 29174670 44.1 ns/op 0 B/op 0 allocs/op
BenchmarkBufferFixedSizeSyncPool
BenchmarkBufferFixedSizeSyncPool-8 38488425 28.1 ns/op 0 B/op 0 allocs/op
PASS
ok github.com/thinkeridea/go-extend/pool/benchmark 5.236s
RT
https://github.com/thinkeridea/go-extend/blob/main/exmath/round.go
四舍五入函数存在精度问题,如0.565保留两位小数输出的是0.56而不是0.57
该方法收集于官网 How to write Go code 中的一个代码片段,因曾经面试遇到这个面试题而留心。
近期回答 Go Forum 中关于 [SOLVED] String size of 20 character 中字符串长度截取使用 []rune
类型与字符串类型转换,期望处理安全的 unicode
字符。
我对此方法提出了性能质疑,编写了基于 utf8.DecodeRuneInString
的计算版本,并做了性能测试 相关回复在这里 发现两个种方法性能差距惊人。
我想到了 go-extend 中的 exstrings.Reverse
方法也是用了类似的类型转换,所以我做了一个小的实验来测试不同实现的性能。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.