{"id":21626952,"url":"https://github.com/komuw/ote","last_synced_at":"2025-04-11T12:46:34.847Z","repository":{"id":48716653,"uuid":"286288170","full_name":"komuw/ote","owner":"komuw","description":"ote updates a packages' go.mod file with a comment next to all dependencies that are test dependencies; identifying them as such.","archived":false,"fork":false,"pushed_at":"2024-10-01T05:51:41.000Z","size":403,"stargazers_count":37,"open_issues_count":5,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-25T09:03:38.966Z","etag":null,"topics":["dependency","go","golang","mod","modules"],"latest_commit_sha":null,"homepage":"","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/komuw.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","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":"2020-08-09T17:49:28.000Z","updated_at":"2025-02-18T09:40:42.000Z","dependencies_parsed_at":"2024-06-19T11:14:18.560Z","dependency_job_id":"a87db922-bc6e-49dd-9250-927aa2caa1b5","html_url":"https://github.com/komuw/ote","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/komuw%2Fote","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/komuw%2Fote/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/komuw%2Fote/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/komuw%2Fote/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/komuw","download_url":"https://codeload.github.com/komuw/ote/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248402546,"owners_count":21097331,"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":["dependency","go","golang","mod","modules"],"created_at":"2024-11-25T01:14:55.950Z","updated_at":"2025-04-11T12:46:34.822Z","avatar_url":"https://github.com/komuw.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## ote          \n\n![ote ci](https://github.com/komuw/ote/workflows/ote%20ci/badge.svg?branch=main)\n[![codecov](https://codecov.io/gh/komuw/ote/branch/main/graph/badge.svg)](https://codecov.io/gh/komuw/ote)\n[![PkgGoDev](https://pkg.go.dev/badge/https://pkg.go.dev/github.com/komuw/ote)](https://pkg.go.dev/github.com/komuw/ote)\n[![Go Report Card](https://goreportcard.com/badge/github.com/komuw/ote)](https://goreportcard.com/report/github.com/komuw/ote)\n\n\n`ote` updates a packages' `go.mod` file with a comment next to all dependencies that are test dependencies; identifying them as such.   \n\nIt's name is derived from Kenyan hip hop artiste, `Oteraw`(One third of the hiphop group `Kalamashaka`).                               \n\nBy default, `go` and its related tools(`go mod` etc) do not differentiate regular dependencies from test ones when updating/writing the `go.mod` file.    \nThere are various reasons why this is so, see [go/issues/26955](https://github.com/golang/go/issues/26955) \u0026 [go/issues/26913](https://github.com/golang/go/issues/26913)      \nThus `ote` fills that missing gap.   \nIt is not perfect, but it seems to work. See [How it works](#how-it-works)        \n\nFor an example of a project using `ote`, see: [ong/go.mod](https://github.com/komuw/ong/blob/v0.0.73/go.mod)                \n\n\n## Installation\n\n```shell\ngo install github.com/komuw/ote@latest\n```           \n\n\n## Usage\n```bash\note --help\n```\n```bash\nexamples:\n\n  ote .               # update go.mod in the current directory\n        \n  ote -f /someDir     # update go.mod in the /someDir directory\n\n  ote -r              # write to stdout instead of updating go.mod in the current directory\n\n  ote -f /someDir -r  # write to stdout instead of updating go.mod in the /someDir directory\n```\n\nIf your application has a `go.mod` file like the following;\n```bash\nmodule github.com/pkg/myPkg\n\ngo 1.17\n\nrequire (\n\tgithub.com/Shopify/sarama v1.26.4\n\tgithub.com/google/go-cmp v0.5.0\n\tgithub.com/nats-io/nats.go v1.10.0\n\tgithub.com/stretchr/testify v1.6.1 // priorComment\n\tgolang.org/x/mod v0.3.0\n)\n\nrequire (\n\tgithub.com/golang/protobuf v1.4.2 // indirect\n\tgithub.com/nats-io/nats-server/v2 v2.1.7 // indirect\n)\n```\nrunning `ote` will update the `go.mod` to the following;\n```bash\nmodule github.com/pkg/myPkg\n\ngo 1.17\n\nrequire (\n\tgithub.com/Shopify/sarama v1.26.4\n\tgithub.com/nats-io/nats.go v1.10.0\n\tgolang.org/x/mod v0.3.0\n)\n\nrequire (\n\tgithub.com/golang/protobuf v1.4.2 // indirect\n\tgithub.com/nats-io/nats-server/v2 v2.1.7 // indirect\n)\n\nrequire (\n\tgithub.com/google/go-cmp v0.5.0 // test\n\tgithub.com/stretchr/testify v1.6.1 // test; priorComment\n)\n```\nie; assuming that `github.com/google/go-cmp` and `github.com/stretchr/testify` are test-only dependencies in your application.\n\n\n## Features.\n- Update `go.mod` file with a comment `// test` next to any dependencies that are only used in tests.\n- Makes only the minimal of changes to `go.mod` files.\n- Preserves any prior comments that were in existence.\n- If a dependency was a test-only dependency and then it starts been used in other non-test contexts, `ote` will also recognise that and remove the `// test` comment.\n\n\n## How it works  \n1. read `go.mod` file.\n2. get all the imports of all the files used by the package    \n  here we consider all the known build tags(`darwin`, `openbsd`, `riscv64` etc)    \n3. get all the modules of which all the imports belong to.    \n4. find which of those are test-only modules.   \n5. update `go.mod` with a comment(`// test`) next to all the test dependencies.\n\n\n## Inspiration(Hat tip)\n1. [`x/mod`](https://pkg.go.dev/golang.org/x/mod).\n2. [`go/packages`](https://pkg.go.dev/golang.org/x/tools/go/packages).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkomuw%2Fote","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkomuw%2Fote","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkomuw%2Fote/lists"}