go-interview's Issues
没有限制goroutine资源的使用
没有限制goroutine资源的使用,遇上具有超多文件的目录,很可能就耗尽系统资源了
降低耦合
现在的整个项目就一个main文件,没有区分功能,能否将项目细化,解耦?
命令行参数的缺失
直接使用os.Args获取参数,这样的做法挺蛋疼啊
CountFile 与 GetFilePath
为了获取文件个数,和文件路径。进行了两次filepath.Walk,这样的解决方案是否不妥?
对超大文件的处理,会造成内存被耗尽,或者缓冲区溢出
你的文件处理缓冲区才8k,很有可能造成blocks这个整数溢出了,应该有更加优雅的写法,你这段代码有些复杂而不优雅
blocks := uint64(math.Ceil(float64(filesize) / float64(filechunk))) // <----此处仍然有问题
hash := sha1.New()
for i := uint64(0); i < blocks; i++ {
blocksize := int(math.Min(filechunk, float64(filesize-int64(i*filechunk))))
buf := make([]byte, blocksize)
file.Read(buf)
io.WriteString(hash, string(buf))
}
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.