{"id":16410839,"url":"https://github.com/natefinch/atomic","last_synced_at":"2025-05-16T04:04:25.255Z","repository":{"id":32166572,"uuid":"35739800","full_name":"natefinch/atomic","owner":"natefinch","description":"atomic is a go package for atomic file writing","archived":false,"fork":false,"pushed_at":"2022-05-24T09:05:55.000Z","size":11,"stargazers_count":200,"open_issues_count":8,"forks_count":12,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-08T14:08:54.586Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/natefinch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-16T20:51:00.000Z","updated_at":"2025-02-20T08:49:12.000Z","dependencies_parsed_at":"2022-09-03T03:35:40.961Z","dependency_job_id":null,"html_url":"https://github.com/natefinch/atomic","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/natefinch%2Fatomic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/natefinch%2Fatomic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/natefinch%2Fatomic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/natefinch%2Fatomic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/natefinch","download_url":"https://codeload.github.com/natefinch/atomic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254464891,"owners_count":22075570,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T06:43:59.225Z","updated_at":"2025-05-16T04:04:25.234Z","avatar_url":"https://github.com/natefinch.png","language":"Go","readme":"# atomic\n    import \"github.com/natefinch/atomic\"\natomic is a go package for atomic file writing\n\nBy default, writing to a file in go (and generally any language) can fail\npartway through... you then have a partially written file, which probably was\ntruncated when the write began, and bam, now you've lost data.\n\nThis go package avoids this problem, by writing first to a temp file, and then\noverwriting the target file in an atomic way.  This is easy on linux, os.Rename\njust is atomic.  However, on Windows, os.Rename is not atomic, and so bad things\ncan happen.  By wrapping the windows API moveFileEx, we can ensure that the move\nis atomic, and we can be safe in knowing that either the move succeeds entirely,\nor neither file will be modified.\n\n\n## func ReplaceFile\n``` go\nfunc ReplaceFile(source, destination string) error\n```\nReplaceFile atomically replaces the destination file or directory with the\nsource.  It is guaranteed to either replace the target file entirely, or not\nchange either file.\n\n\n## func WriteFile\n``` go\nfunc WriteFile(filename string, r io.Reader) (err error)\n```\nWriteFile atomically writes the contents of r to the specified filepath.  If\nan error occurs, the target file is guaranteed to be either fully written, or\nnot written at all.  WriteFile overwrites any file that exists at the\nlocation (but only if the write fully succeeds, otherwise the existing file\nis unmodified).\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnatefinch%2Fatomic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnatefinch%2Fatomic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnatefinch%2Fatomic/lists"}