Hi,

I have a long running hobby program with a code: 

var (
   url      = "https://example.com";
   lastBody []byte
)


func get(client *http.Client, dir) (changed bool, data []byte, err error) {

   resp, err := client.Get(url)
   if err != nil {
      return false, nil, err
   }
   if resp.StatusCode != http.StatusOK {
      log.Printf("status code: %d", resp.StatusCode)
      return false, nil,  nil
   }
   body, err := ioutil.ReadAll(resp.Body)
   if err != nil {
      return false, nil, err
   }
   if bytes.Compare(body, lastBody) == 0 {
      logrus.Info("data is equal")
      return false, data, nil
   }

   lastBody = body
   log.Printf("got %dB data", len(body))

   dir = path.Join(dir, t.Format("2006/01/02"))
   if err = os.MkdirAll(dir, defaultDirPerm); err != nil {
      log.Print("failed to create a dir")
   }
   p := path.Join(dir, fmt.Sprintf("%d.json", t.Unix()))

   return true, body, ioutil.WriteFile(p, body, 0640)
}


After around 14 days the process stops writing files. However, it executes 
os.WriteFile and does not return any error.
The function is called repeatedly every N second (~40-60sec.). It produces 
around 1700 files a day.

Any ideas?

I've found https://github.com/golang/go/issues/14491 and some other threads 
but not a conclusive result.

Cheers, Paweł Szczur

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to