{"action":"created","issue":{"url":"https://api.github.com/repos/golang/go/issues/14491","repository_url":"https://api.github.com/repos/golang/go","labels_url":"https://api.github.com/repos/golang/go/issues/14491/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/14491/comments","events_url":"https://api.github.com/repos/golang/go/issues/14491/events","html_url":"https://github.com/golang/go/issues/14491","id":136066467,"number":14491,"title":"io/ioutil: WriteFile does not write content to file","user":{"login":"TheHippo","id":199056,"avatar_url":"https://avatars.githubusercontent.com/u/199056?v=3","gravatar_id":"","url":"https://api.github.com/users/TheHippo","html_url":"https://github.com/TheHippo","followers_url":"https://api.github.com/users/TheHippo/followers","following_url":"https://api.github.com/users/TheHippo/following{/other_user}","gists_url":"https://api.github.com/users/TheHippo/gists{/gist_id}","starred_url":"https://api.github.com/users/TheHippo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheHippo/subscriptions","organizations_url":"https://api.github.com/users/TheHippo/orgs","repos_url":"https://api.github.com/users/TheHippo/repos","events_url":"https://api.github.com/users/TheHippo/events{/privacy}","received_events_url":"https://api.github.com/users/TheHippo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/golang/go/milestones/31","html_url":"https://github.com/golang/go/milestones/Go1.7","labels_url":"https://api.github.com/repos/golang/go/milestones/31/labels","id":1414133,"number":31,"title":"Go1.7","description":"","creator":{"login":"bradfitz","id":2621,"avatar_url":"https://avatars.githubusercontent.com/u/2621?v=3","gravatar_id":"","url":"https://api.github.com/users/bradfitz","html_url":"https://github.com/bradfitz","followers_url":"https://api.github.com/users/bradfitz/followers","following_url":"https://api.github.com/users/bradfitz/following{/other_user}","gists_url":"https://api.github.com/users/bradfitz/gists{/gist_id}","starred_url":"https://api.github.com/users/bradfitz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bradfitz/subscriptions","organizations_url":"https://api.github.com/users/bradfitz/orgs","repos_url":"https://api.github.com/users/bradfitz/repos","events_url":"https://api.github.com/users/bradfitz/events{/privacy}","received_events_url":"https://api.github.com/users/bradfitz/received_events","type":"User","site_admin":false},"open_issues":211,"closed_issues":51,"state":"open","created_at":"2015-11-16T16:57:07Z","updated_at":"2016-02-24T18:42:32Z","due_on":"2016-07-31T07:00:00Z","closed_at":null},"comments":4,"created_at":"2016-02-24T13:48:44Z","updated_at":"2016-02-24T19:07:01Z","closed_at":null,"body":"Using Go 1.5.3 on Linux/amd64:\r\n\r\nWriting a file like:\r\n\r\n```go\r\nerr := ioutil.WriteFile(\"temp\", []byte(\"foo\"), 0644)\r\nif err != nil {\r\n\t// error handling\r\n}\r\n// read \"temp\"\r\n```\r\n\r\nReading the file content of `temp` immediately after writing it sometimes indicates the content hasn't been written to the file. Looking at the source code of [`WriteFile`](https://golang.org/src/io/ioutil/ioutil.go?s=2520:2588#L66) it seems like a call to `Sync()` is missing.\r\n\r\nP.S.: Tested with larger content."},"comment":{"url":"https://api.github.com/repos/golang/go/issues/comments/188408472","html_url":"https://github.com/golang/go/issues/14491#issuecomment-188408472","issue_url":"https://api.github.com/repos/golang/go/issues/14491","id":188408472,"user":{"login":"TheHippo","id":199056,"avatar_url":"https://avatars.githubusercontent.com/u/199056?v=3","gravatar_id":"","url":"https://api.github.com/users/TheHippo","html_url":"https://github.com/TheHippo","followers_url":"https://api.github.com/users/TheHippo/followers","following_url":"https://api.github.com/users/TheHippo/following{/other_user}","gists_url":"https://api.github.com/users/TheHippo/gists{/gist_id}","starred_url":"https://api.github.com/users/TheHippo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheHippo/subscriptions","organizations_url":"https://api.github.com/users/TheHippo/orgs","repos_url":"https://api.github.com/users/TheHippo/repos","events_url":"https://api.github.com/users/TheHippo/events{/privacy}","received_events_url":"https://api.github.com/users/TheHippo/received_events","type":"User","site_admin":false},"created_at":"2016-02-24T19:07:01Z","updated_at":"2016-02-24T19:07:01Z","body":"After some digging a few more facts about when/how this happens:\r\n\r\n- there is some real load on the file system\r\n- we do not read from go process:\r\n  - as soon as the file is written a process (written in C) gets a signal to reload the file and there a about 1:5 chance the config file is empty\r\n\r\nWriting the file \"manually\" and calling `Sync()` mitigates this issue completely "}}