{"id":23611075,"url":"https://github.com/acikgozb/gtee","last_synced_at":"2025-11-06T04:30:30.891Z","repository":{"id":269747734,"uuid":"908344664","full_name":"acikgozb/gtee","owner":"acikgozb","description":"Go implementation of `tee`, a GNU Coreutils tool. Work in progress.","archived":false,"fork":false,"pushed_at":"2025-01-01T20:35:27.000Z","size":33,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-01T21:33:22.650Z","etag":null,"topics":["cli","gnu-coreutils","go","tee"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/acikgozb.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":"2024-12-25T20:05:22.000Z","updated_at":"2025-01-01T20:35:31.000Z","dependencies_parsed_at":"2024-12-25T21:17:45.323Z","dependency_job_id":"55345915-edf2-4563-9238-c553353e3041","html_url":"https://github.com/acikgozb/gtee","commit_stats":null,"previous_names":["acikgozb/gtee"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acikgozb%2Fgtee","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acikgozb%2Fgtee/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acikgozb%2Fgtee/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acikgozb%2Fgtee/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/acikgozb","download_url":"https://codeload.github.com/acikgozb/gtee/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239483369,"owners_count":19646424,"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":["cli","gnu-coreutils","go","tee"],"created_at":"2024-12-27T16:13:03.498Z","updated_at":"2025-11-06T04:30:30.822Z","avatar_url":"https://github.com/acikgozb.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `gtee`\n\nA Go implementation of `tee`, a GNU Coreutils tool. The original implementation in C can be checked on [here](https://github.com/coreutils/coreutils/blob/master/src/tee.c).\n\n## Table of Contents\n\n\u003c!--toc:start--\u003e\n\n- [Installation](#a-idinstallation-installation)\n  - [`go install`](#go-install)\n  - [Prebuilt Binaries](#prebuilt-binaries)\n- [Usage](#a-idusage-usage)\n- [The Implementation](#a-idthe-implementation-the-implementation)\n- [Tests](#a-idtests-tests)\n- [Benchmarks](#a-idbenchmarks-benchmarks)\n- [TODO](#a-idtodo-todo)\n\u003c!--toc:end--\u003e\n\n## \u003ca id='installation' /\u003e Installation\n\n`gtee` is available on Linux and MacOS.\n\n### \u003ca id='go-install' /\u003e `go install`\n\nAs a Go project, `gtee` can be installed via `go install`, like below:\n\n```bash\ngo install github.com/acikgozb/gtee\n```\n\n### \u003ca id='prebuilt-binaries' /\u003e Prebuilt Binaries\n\nIf you wish to not install Go on your machine just to install `gtee`, you can download a prebuilt binary from the release page.\nThe binaries are available for the platforms below:\n\n- _x86_64_ (amd64) Linux\n- _arm64_ Darwin (macOS)\n\nYou can download the version you wish to use and then extract the binary from the archive to wherever you want.\n\nOnce downloaded and put into a directory, you can verify the installation by simply running:\n\n```bash\ngtee -h\n```\n\nIf you see the usage, then you are all set!\n\nDon't forget to make sure the binary is under `$PATH` to be able to use it without manually entering the location of the binary itself.\nTo verify whether `gtee` is under path, you can run:\n\n```bash\nwhich gtee\n```\n\nIf `which` returns a path, that means you can successfully use `gtee` without specifying the full path of the binary.\n\n## \u003ca id='usage' /\u003e Usage\n\n`gtee` is designed to be used as a drop in replacement of `tee` with the exception of:\n\n- Merging shorthand options like `-ai`,\n- Environment variables that alter the language of diagnostic messages.\n\nHere are the supported usages:\n\n```bash\n# Write to both stdout and a file named \"example.txt\".\n$ echo \"write me!\" | gtee example.txt\n\n# Use input redirection and write \"input.txt\" to both stdout and a file named \"example.txt\".\n$ gtee example.txt \u003c input.txt\n\n# Write \"input.txt\" only to a file named \"example.txt\", not stdout.\n$ gtee example.txt \u003e /dev/null \u003c input.txt\n\n# Append only to a file named \"example.txt\".\n$ echo \"append me!\" | gtee -a example.txt \u003e /dev/null\n$ echo \"append me!\" | gtee --a example.txt \u003e /dev/null\n$ echo \"append me!\" | gtee -append example.txt \u003e /dev/null\n$ echo \"append me!\" | gtee --append example.txt \u003e /dev/null\n\n# Ignore SIGINT during a long execution.\n$ echo \"write me, a super long input!\" | gtee -i example.txt \u003e /dev/null\n$ echo \"write me, a super long input!\" | gtee --i example.txt \u003e /dev/null\n$ echo \"write me, a super long input!\" | gtee -ignore example.txt \u003e /dev/null\n$ echo \"write me, a super long input!\" | gtee --ignore example.txt \u003e /dev/null\n\n# Attempting to send a SIGINT signal results in a diagnostic message on stdout, not err.\n$ echo \"write me, a super long input!\" | gtee -i example.txt \u003e /dev/null\n^Cgtee: The SIGINT signal is ignored.\n\n# Append to a file named \"example.txt\" and ignore the SIGINT signal.\n$ echo \"append me, a super long input!\" | gtee -a -i example.txt \u003e /dev/null\n$ echo \"append me, a super long input!\" | gtee --a --i example.txt \u003e /dev/null\n$ echo \"append me, a super long input!\" | gtee -append -ignore example.txt \u003e /dev/null\n$ echo \"append me, a super long input!\" | gtee --append --ignore example.txt \u003e /dev/null\n```\n\nRunning `gtee` with `-h` or with a non-supported flag will result in showing the usage of the program, which is inspired from the man page of `tee`:\n\n```bash\n# Show usage:\n$ gtee -h # --h, -help, --help\n\nNAME\n\tgtee - Duplicate standard input.\n\nSYNOPSIS\n\tgtee [-a] [-i] [file ...]\n\nOPTIONS\n\t-i, --i, -ignore, --ignore\tIgnore the SIGINT signal.\n\t-a, --a, -append, --append\tAppend the output to the files rather than overwriting them.\n\nEXAMPLES\nSend the echoed message to both stdout and a file called greetings.txt:\n\n\t$ echo \"Hello\" | gtee greetings.txt\n\tHello\n```\n\n## \u003ca id='the-implementation' /\u003e The Implementation\n\nThe implemenation is done based on the POSIX specification of `tee`.\n\nYou can see the specification on [here](https://pubs.opengroup.org/onlinepubs/9799919799/).\nSearch for `tee` from index and you will see the document.\n\n## \u003ca id='tests' /\u003e Tests\n\nEach test is written to satisfy a different part of the specification.\nTo see which requirement is tested in a given test, search the content of the `expected` variable on the specification.\n\n## \u003ca id='benchmarks' /\u003e Benchmarks\n\nCurrently, there is only one simple benchmark which compares both `tee` and `gtee` on a 100MB file created by `dd`.\nCheck out `BenchmarkTee` and `BenchmarkGtee` for more information.\n\nHere is a sample comparison to showcase a result.\nKeep in mind that the times you get on your own host may not match with these:\n\n```bash\n$ go test -bench=. -benchtime 100x -benchmem\npkg: github.com/acikgozb/gtee\nBenchmarkTee-10     \t     100\t  55095693 ns/op\t    5940 B/op\t      22 allocs/op\nBenchmarkGtee-10    \t     100\t  49339303 ns/op\t    5988 B/op\t      22 allocs/op\nPASS\nok  \tgithub.com/acikgozb/gtee\t12.470s\n```\n\n## \u003ca id='todo' /\u003e TODO\n\n- `man gtee`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facikgozb%2Fgtee","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Facikgozb%2Fgtee","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facikgozb%2Fgtee/lists"}