Hacker News new | ask | show | jobs
by shakna 404 days ago
listFiles is not sorted. It provides the files in the order that the OS provides them. That it's ordered on your machine, probably has to do with when the underlying nodes were created. But that's not going to much work in production.

    dirInfo, err := dir.Readdir(0)
    if err != nil {
        return nil, err
     }

    names := make([]string, len(dirInfo))
     for i, fileInfo := range dirInfo {
          names[i] = fileInfo.Name()
     }
1 comments

Yeah that was what I was afraid of. I thought I saw in the caddy code that they did a sort on file name, but I must have misread it. Thanks for responding!

Edit: after looking more closely at sprig, the solve was sortAlpha