logoalt Hacker News

jprokay13yesterday at 3:26 PM2 repliesview on HN

I went all in on using Caddy for rendering my website and blog, but I’m encountering a frustrating issue that I’m not sure how to solve. The feed on my site uses the listFiles feature to populate from a directory. I take care to name things so ordering is preserved. No problems on my machine getting the feed ordered correctly. However, when deployed to Railway via a container, the ordering is all wrong. Any thoughts on how to debug?


Replies

shaknayesterday at 3:51 PM

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()
     }
show 1 reply
indigodaddyyesterday at 8:44 PM

I'd love more info about your process!