Giter Site home page Giter Site logo

go-interview's People

Contributors

cuijiabin avatar

Watchers

 avatar

go-interview's Issues

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))
}

降低耦合

现在的整个项目就一个main文件,没有区分功能,能否将项目细化,解耦?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.