{"id":26823735,"url":"https://github.com/bytecodeagency/tempdir-dao","last_synced_at":"2025-03-30T09:16:29.934Z","repository":{"id":101997708,"uuid":"219211348","full_name":"BytecodeAgency/tempdir-dao","owner":"BytecodeAgency","description":"A temporary directory DAO (data-access object) for use in Golang, to manage a folder with multiple temporary files.","archived":false,"fork":false,"pushed_at":"2019-12-16T09:34:03.000Z","size":23,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-13T23:03:50.233Z","etag":null,"topics":["bytecode","bytecode-agency","bytecodeagency","dao","data-access-object","go","golang","tempdir"],"latest_commit_sha":null,"homepage":"https://bytecode.nl","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BytecodeAgency.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":"2019-11-02T20:41:28.000Z","updated_at":"2024-06-19T08:00:28.551Z","dependencies_parsed_at":null,"dependency_job_id":"eb9380e4-e716-46b0-8685-99900f92dfec","html_url":"https://github.com/BytecodeAgency/tempdir-dao","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BytecodeAgency%2Ftempdir-dao","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BytecodeAgency%2Ftempdir-dao/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BytecodeAgency%2Ftempdir-dao/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BytecodeAgency%2Ftempdir-dao/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BytecodeAgency","download_url":"https://codeload.github.com/BytecodeAgency/tempdir-dao/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246296582,"owners_count":20754635,"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":["bytecode","bytecode-agency","bytecodeagency","dao","data-access-object","go","golang","tempdir"],"created_at":"2025-03-30T09:16:29.285Z","updated_at":"2025-03-30T09:16:29.895Z","avatar_url":"https://github.com/BytecodeAgency.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Temporary Directory Data-Access Object [![Build Status](https://travis-ci.com/BytecodeAgency/tempdir-dao.svg?branch=master)](https://travis-ci.com/BytecodeAgency/tempdir-dao)\n\n_Warning: this library has been developed for R\u0026D purposes for an internal project at Bytecode. This package is not tested for production usage and it is not (yet) feature complete. For example, using sub-directories is not supported (yet)_\n\n## Why don't you use `ioutil.TempFile` and/or `os.TempDir`\n\nThis package was created specifically to work with multiple files in a grouped together. This rules out using `iouril.TempFile` as it only works with single files.\n\nUsing `os.TempDir` was ruled out as it [says in the documentation](https://golang.org/pkg/os/#TempDir) that `The directory is neither guaranteed to exist nor have accessible permissions`, while this directory does not delete the files/directory until that method has been called explicitly.\n\n\n\n## Installation\n\nUse `go get` or your Go package manager choice:\n\n```\ngo get -u github.com/BytecodeAgency/tempdir-dao\n```\n\n## Usage\n\nTo create a new DAO, use \n\n```go\ntempDirDAO, err := tempdirdao.NewTempFileAccess() // returns `(*TempFileAccess, error)`\n```\n\nThe following methods are available:\n\n| Method | Functionality | Arguments | Returns |\n| ------ | ------------- | --------- | ------- |\n| `LoadDirContents` | Lists contents of temp directory | `()` | `([]os.FileInfo, error`\n| `GetFullFilePath` | Gets the full file path of a file in the temp dir | `(filename string)`  | `(string, error)`\n| `LoadFileContents` | Loads contents of a file in the temp dir | `()` | `([]byte, error)`\n| `SaveFile` | Created or overwrites a file in the temp dir | `(filename string, fileContents []byte, permissions os.FileMode)` | `error`\n| `RemoveTempFileAccess` | Removes the temp dir | `()` | `error`\n \n\n_Note: you never need to include the temporary directory name in the arguments for methods_\n\n## Example\n\n```go\npackage main\n\nimport (\n    \"github.com/BytecodeAgency/tempdir-dao\"\n    \"log\"\n)\n\nconst filename = \"somefile.ext\"\n\nfunc main () {\n    fileContents := funcThatReturnsString()\n    \n    tfa, err := tempdirdao.NewTempFileAccess()\n    defer tfa.RemoveTempFileAccess()\n    if err != nil {\n    \tlog.Fatal(err)\n    }\n    err = tfa.SaveFile(filename, fileContents, 0644)\n    if err != nil {\n        log.Fatal(err)\n    }\n    \n    fullFilePath, err := tfa.GetFullFilePath(filename)\n    if err != nil {\n        log.Fatal(err)\n    }\n    funcThatUsesTheTempFile(fullFilePath)\n}\n```\n\n## License\n\nGNU Lesser General Public License (LGPL-3.0)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbytecodeagency%2Ftempdir-dao","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbytecodeagency%2Ftempdir-dao","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbytecodeagency%2Ftempdir-dao/lists"}