{"id":26018791,"url":"https://github.com/jcbhmr/go-tempy","last_synced_at":"2025-10-09T05:41:01.512Z","repository":{"id":274576739,"uuid":"923336073","full_name":"jcbhmr/go-tempy","owner":"jcbhmr","description":"📂 The tempy npm package ported to Go","archived":false,"fork":false,"pushed_at":"2025-01-30T01:40:49.000Z","size":29,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-13T11:58:05.481Z","etag":null,"topics":["go","golang","port","temporary-files","tempy","tmpdir"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/jcbhmr/go-tempy/v3","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/jcbhmr.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":"2025-01-28T03:40:26.000Z","updated_at":"2025-01-30T01:44:55.000Z","dependencies_parsed_at":"2025-03-06T06:44:40.681Z","dependency_job_id":null,"html_url":"https://github.com/jcbhmr/go-tempy","commit_stats":null,"previous_names":["jcbhmr/go-tempy"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/jcbhmr/go-tempy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcbhmr%2Fgo-tempy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcbhmr%2Fgo-tempy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcbhmr%2Fgo-tempy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcbhmr%2Fgo-tempy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jcbhmr","download_url":"https://codeload.github.com/jcbhmr/go-tempy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcbhmr%2Fgo-tempy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000741,"owners_count":26082932,"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","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["go","golang","port","temporary-files","tempy","tmpdir"],"created_at":"2025-03-06T06:34:30.978Z","updated_at":"2025-10-09T05:41:01.473Z","avatar_url":"https://github.com/jcbhmr.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tempy for Go\n\n📂 The [tempy npm package](https://www.npmjs.com/package/tempy) ported to Go\n\n\u003ctable align=center\u003e\u003ctd\u003e\n\n```go\nfmt.Println(tempy.TemporaryFile(\u0026tempy.FileOptions{Extension: \"png\"}))\n// Possible output: /tmp/a1b2c3d4a1b2c3d4a1b2c3d4a1b2c3d4.png\n```\n\n```go\np, err = tempy.TemporaryDirectory(\u0026tempy.DirectoryOptions{Prefix: \"name_\"})\nif err != nil {\n  log.Fatal(err)\n}\nlog.Println(p)\n// Possible output: /tmp/name_a1b2c3d4a1b2c3d4a1b2c3d4a1b2c3d4\n```\n\n\u003c/table\u003e\n\n\u003cp align=center\u003e\n  \u003ca href=\"https://pkg.go.dev/github.com/jcbhmr/go-tempy/v3\"\u003eDocs\u003c/a\u003e\n  | \u003ca href=\"https://github.com/jcbhmr/go-tempy\"\u003eGitHub\u003c/a\u003e\n\u003c/p\u003e\n\n🔗 Properly resolves `TMPDIR=/dirsymlink` symlinks \\\n🐿️ Uses Go idioms while maintaining the same API surface as tempy \\\n📁 Great for quickly writing some data to a temporary file\n\n## Installation\n\n![Go](https://img.shields.io/badge/Go-00ADD8?style=for-the-badge\u0026logo=Go\u0026logoColor=FFFFFF)\n\n```sh\ngo get github.com/jcbhmr/go-tempy/v3\n```\n\n## Usage\n\n![Go](https://img.shields.io/badge/Go-00ADD8?style=for-the-badge\u0026logo=Go\u0026logoColor=FFFFFF)\n\n```go\npackage main\n\nimport (\n  \"fmt\"\n\n  \"github.com/jcbhmr/go-tempy/v3\"\n)\n\nfunc main() {\n  log.Println(tempy.TemporaryFile(nil))\n\n  log.Println(tempy.TemporaryFile(\u0026tempy.FileOptions{Extension: \"png\"}))\n\n  log.Println(tempy.TemporaryFile(\u0026tempy.FileOptions{Name: \"unicorn.png\"}))\n\n  p, err = tempy.TemporaryDirectory(nil)\n  if err != nil {\n    log.Fatal(err)\n  }\n  log.Println(p)\n\n  p, err = tempy.TemporaryDirectory(\u0026tempy.DirectoryOptions{Prefix: \"name_\"})\n  if err != nil {\n    log.Fatal(err)\n  }\n  log.Println(p)\n\n  // Possible output:\n  // /tmp/a1b2c3d4a1b2c3d4a1b2c3d4a1b2c3d4\n  // /tmp/a1b2c3d4a1b2c3d4a1b2c3d4a1b2c3d4.png\n  // /tmp/unicorn.png\n  // /tmp/a1b2c3d4a1b2c3d4a1b2c3d4a1b2c3d4\n  // /tmp/name_a1b2c3d4a1b2c3d4a1b2c3d4a1b2c3d4\n}\n```\n\n[📚 See pkg.go.dev/github.com/jcbhmr/go-tempy/v3 for more docs](https://pkg.go.dev/github.com/jcbhmr/go-tempy/v3)\n\n## Development\n\n![Go](https://img.shields.io/badge/Go-00ADD8?style=for-the-badge\u0026logo=Go\u0026logoColor=FFFFFF)\n\nThis package attempts to mirror the functionality and API surface of [the tempy npm package](https://www.npmjs.com/package/tempy). To that end, we need to convert some JavaScript concepts to Go concepts.\n\n- Union types like `TypedArray | Buffer` are mapped to `any` with a `switch x.(type)` or `if v, ok := x.(T); ok`. Doc comments should be included to clarify possible types.\n- If possible, JavaScript standard library or Node.js standard library types are mapped to Go standard library types.\n- Node.js `Buffer` is `[]byte`. `bytes.Buffer` might seem like a good fit but it implements `Reader` and `Writer` interfaces which we don't want.\n- `ArrayBuffer` is `[]byte`. `bytes.Buffer` offers too much functionality.\n- ECMA `TypedArray` variants are `[]\u003cnumeric\u003e`. Note that `byte` is an alias of `uint8`.\n- ECMA `DataView` is `[]byte`. Byte slices can be views into other byte slices so this works OK.\n- Node.js R/W streams are `io.(Read|Write)Closer` interfaces. Node.js streams are closed by the stream's consumer. We do the same here.\n- All `Promise\u003cT\u003e` values are flattened to just `T`. We let the user spawn goroutines if they want things to be asynchronous.\n\nAlso try to keep the version tags in sync. v1.0.0 of tempy on npm should correspond with v1.0.0 of this module.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcbhmr%2Fgo-tempy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjcbhmr%2Fgo-tempy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcbhmr%2Fgo-tempy/lists"}