Code Room
Code reviewMediumcr-g617
Subject Storage fd leakLevel Mid–Senior~18 minCommon in Storage & CDN interviewsIndustries Software development

Question

Review this Go function that finds the largest file under a directory tree.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.

Talk through your review
Code to reviewgo
func largestFile(root string) (string, int64, error) {    var bestPath string    var bestSize int64    err := filepath.Walk(root, func(p string, info os.FileInfo, err error) error {        if err != nil || info.IsDir() {            return err        }        f, err := os.Open(p)        if err != nil {            return err        }        st, _ := f.Stat()        if st.Size() > bestSize {            bestSize = st.Size()            bestPath = p        }        return nil    })    return bestPath, bestSize, err}
Run or narrate your approach, then ask the coach.