{"id":16834920,"url":"https://github.com/dchest/safefile","last_synced_at":"2025-06-26T19:37:09.095Z","repository":{"id":12152301,"uuid":"14745998","full_name":"dchest/safefile","owner":"dchest","description":"Go package safefile implements safe \"atomic\" saving of files.","archived":false,"fork":false,"pushed_at":"2023-12-05T15:03:09.000Z","size":213,"stargazers_count":81,"open_issues_count":1,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-20T01:11:16.044Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dchest.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-11-27T12:08:51.000Z","updated_at":"2025-02-19T17:45:19.000Z","dependencies_parsed_at":"2024-06-18T14:02:19.126Z","dependency_job_id":null,"html_url":"https://github.com/dchest/safefile","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dchest/safefile","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dchest%2Fsafefile","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dchest%2Fsafefile/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dchest%2Fsafefile/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dchest%2Fsafefile/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dchest","download_url":"https://codeload.github.com/dchest/safefile/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dchest%2Fsafefile/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262133374,"owners_count":23264194,"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-13T12:08:23.488Z","updated_at":"2025-06-26T19:37:09.069Z","avatar_url":"https://github.com/dchest.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# safefile\n\n[![Build Status](https://travis-ci.org/dchest/safefile.svg)](https://travis-ci.org/dchest/safefile) [![Windows Build status](https://ci.appveyor.com/api/projects/status/owlifxeekg75t2ho?svg=true)](https://ci.appveyor.com/project/dchest/safefile)\n\nGo package safefile implements safe \"atomic\" saving of files.\n\nInstead of truncating and overwriting the destination file, it creates a\ntemporary file in the same directory, writes to it, and then renames the\ntemporary file to the original name when calling Commit.\n\n\n### Installation\n\n```\n$ go get github.com/dchest/safefile\n```\n\n### Documentation\n\n \u003chttps://godoc.org/github.com/dchest/safefile\u003e\n\n### Example\n\n```go\nf, err := safefile.Create(\"/home/ken/report.txt\", 0644)\nif err != nil {\n\t// ...\n}\n// Created temporary file /home/ken/sf-ppcyksu5hyw2mfec.tmp\n\ndefer f.Close()\n\n_, err = io.WriteString(f, \"Hello world\")\nif err != nil {\n\t// ...\n}\n// Wrote \"Hello world\" to /home/ken/sf-ppcyksu5hyw2mfec.tmp\n\nerr = f.Commit()\nif err != nil {\n    // ...\n}\n// Renamed /home/ken/sf-ppcyksu5hyw2mfec.tmp to /home/ken/report.txt\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdchest%2Fsafefile","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdchest%2Fsafefile","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdchest%2Fsafefile/lists"}