{"id":13721472,"url":"https://github.com/cloudspannerecosystem/yo","last_synced_at":"2026-01-18T09:30:37.248Z","repository":{"id":37885963,"uuid":"154446781","full_name":"cloudspannerecosystem/yo","owner":"cloudspannerecosystem","description":"yo is a command-line tool to generate Go code for Google Cloud Spanner.","archived":false,"fork":false,"pushed_at":"2026-01-09T07:14:09.000Z","size":1931,"stargazers_count":332,"open_issues_count":24,"forks_count":60,"subscribers_count":12,"default_branch":"master","last_synced_at":"2026-01-11T22:33:41.245Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cloudspannerecosystem.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2018-10-24T05:57:22.000Z","updated_at":"2026-01-09T07:14:11.000Z","dependencies_parsed_at":"2023-11-09T12:22:13.553Z","dependency_job_id":"8eb9258d-b4f6-4071-9825-4339d312b16b","html_url":"https://github.com/cloudspannerecosystem/yo","commit_stats":null,"previous_names":["mercari/yo"],"tags_count":25,"template":false,"template_full_name":null,"purl":"pkg:github/cloudspannerecosystem/yo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudspannerecosystem%2Fyo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudspannerecosystem%2Fyo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudspannerecosystem%2Fyo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudspannerecosystem%2Fyo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cloudspannerecosystem","download_url":"https://codeload.github.com/cloudspannerecosystem/yo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudspannerecosystem%2Fyo/sbom","scorecard":{"id":293302,"data":{"date":"2025-08-11","repo":{"name":"github.com/cloudspannerecosystem/yo","commit":"f2465169b3e533522cf747f1b8f41ec1189f4948"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":5.9,"checks":[{"name":"Maintained","score":10,"reason":"16 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 10","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/release.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":10,"reason":"all changesets reviewed","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/cloudspannerecosystem/yo/release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/cloudspannerecosystem/yo/release.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/cloudspannerecosystem/yo/release.yml/master?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Packaging","score":10,"reason":"packaging workflow detected","details":["Info: Project packages its releases by way of GitHub Actions.: .github/workflows/release.yml:9"],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Signed-Releases","score":0,"reason":"Project has not signed or included provenance with any releases.","details":["Warn: release artifact v0.7.0 not signed: https://api.github.com/repos/cloudspannerecosystem/yo/releases/211175341","Warn: release artifact v0.6.1 not signed: https://api.github.com/repos/cloudspannerecosystem/yo/releases/203777908","Warn: release artifact v0.5.7 not signed: https://api.github.com/repos/cloudspannerecosystem/yo/releases/149868334","Warn: release artifact v0.5.6 not signed: https://api.github.com/repos/cloudspannerecosystem/yo/releases/144297871","Warn: release artifact v0.7.0 does not have provenance: https://api.github.com/repos/cloudspannerecosystem/yo/releases/211175341","Warn: release artifact v0.6.1 does not have provenance: https://api.github.com/repos/cloudspannerecosystem/yo/releases/203777908","Warn: release artifact v0.5.7 does not have provenance: https://api.github.com/repos/cloudspannerecosystem/yo/releases/149868334","Warn: release artifact v0.5.6 does not have provenance: https://api.github.com/repos/cloudspannerecosystem/yo/releases/144297871"],"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":7,"reason":"SAST tool is not run on all commits -- score normalized to 7","details":["Warn: 23 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":9,"reason":"1 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GO-2025-3488 / GHSA-6v2p-p543-phr9"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-17T18:51:47.802Z","repository_id":37885963,"created_at":"2025-08-17T18:51:47.802Z","updated_at":"2025-08-17T18:51:47.802Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28534159,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T00:39:45.795Z","status":"online","status_checked_at":"2026-01-18T02:00:07.578Z","response_time":98,"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":[],"created_at":"2024-08-03T01:01:17.519Z","updated_at":"2026-01-18T09:30:37.221Z","avatar_url":"https://github.com/cloudspannerecosystem.png","language":"Go","funding_links":[],"categories":["Tools","Go"],"sub_categories":["ORM"],"readme":"# yo\n\n`yo` is a command-line tool to generate Go code for [Google Cloud Spanner](https://cloud.google.com/spanner/),\nforked from [xo](https://github.com/xo/xo) :rose:.\n\n`yo` uses database schema to generate code by using [Information Schema](https://cloud.google.com/spanner/docs/information-schema). `yo` runs SQL queries against tables in `INFORMATION_SCHEMA` to fetch metadata for a database, and applies the metadata to Go templates to generate code/models to access Cloud Spanner.\n\nPlease feel free to report issues and send pull requests, but note that this\napplication is not officially supported as part of the Cloud Spanner product.\n\n## Installation\n\n[Install Go](https://go.dev/doc/install) and run the following command.\n\n```sh\n# For Go 1.16+\ngo install go.mercari.io/yo@latest\n\n# For Go \u003c1.16\ngo get -u go.mercari.io/yo\n```\n\n## Quickstart\n\nThe following is a quick overview of using `yo` on the command-line:\n\n```sh\n# change to project directory\n$ cd $GOPATH/src/path/to/project\n\n# make an output directory\n$ mkdir -p models\n\n# generate code for a schema\n$ yo $SPANNER_PROJECT_NAME $SPANNER_INSTANCE_NAME $SPANNER_DATABASE_NAME -o models\n```\n\n## Command line options\n\nThe following are `yo`'s command-line arguments and options:\n\n```sh\n$ yo --help\nyo is a command-line tool to generate Go code for Google Cloud Spanner.\n\nUsage:\n  yo PROJECT_NAME INSTANCE_NAME DATABASE_NAME [flags]\n\nExamples:\n  # Generate models from DDL under the models directory\n  yo generate schame.sql --from-ddl -o models\n  \n  # Generate models from DDL under the models directory with custom types\n  yo generate schame.sql --from-ddl -o models --custom-types-file custom_column_types.yml\n  \n  # Generate models under models directory\n  yo $SPANNER_PROJECT_NAME $SPANNER_INSTANCE_NAME $SPANNER_DATABASE_NAME -o models\n\n  # Generate models under models directory with custom types\n  yo $SPANNER_PROJECT_NAME $SPANNER_INSTANCE_NAME $SPANNER_DATABASE_NAME -o models --custom-types-file custom_column_types.yml\n\nFlags:\n      --custom-type-package string   Go package name to use for custom or unknown types\n      --custom-types-file string     custom table field type definition file\n  -h, --help                         help for yo\n      --ignore-fields stringArray    fields to exclude from the generated Go code types\n      --ignore-tables stringArray    tables to exclude from the generated Go code types\n      --inflection-rule-file string  custom inflection rule file\n  -o, --out string                   output path or file name\n  -p, --package string               package name used in generated Go code\n      --single-file                  toggle single file output\n      --suffix string                output file suffix (default \".yo.go\")\n      --tags string                  build tags to add to package header\n      --template-path string         user supplied template path\n      --underscore                   toggle underscores in file names\n```\n\n## Generated code\n\n`yo` generates 1 file per table by default. Each file has struct, metadata and methods for that table.\n\n### struct\n\nFrom this table definition:\n\n```\nCREATE TABLE Examples (\n  PKey STRING(32) NOT NULL,\n  Num INT64 NOT NULL,\n  CreatedAt TIMESTAMP NOT NULL,\n) PRIMARY KEY(PKey);\n```\n\nThis struct is generated:\n\n```golang\ntype Example struct {\n\tPKey      string    `spanner:\"PKey\" json:\"PKey\"`           // PKey\n\tNum       int64     `spanner:\"Num\" json:\"Num\"`             // Num\n\tCreatedAt time.Time `spanner:\"CreatedAt\" json:\"CreatedAt\"` // CreatedAt\n}\n```\n\n### Mutation methods\n\nAn operation against a table is represented as mutation in Cloud Spanner. `yo` generates methods to create mutations to modify a table.\n\n* Insert\n   * A wrapper method of `spanner.Insert`, which embeds struct values implicitly to insert a new record with struct values.\n* Update\n   * A wrapper method of `spanner.Update`, which embeds struct values implicitly to update all columns into struct values.\n* InsertOrUpdate\n   * A wrapper method of `spanner.InsertOrUpdate`, which embeds struct values implicitly to insert a new record or update all columns to struct values.\n* UpdateColumns\n   * A wrapper method of `spanner.Update`, which updates specified columns into struct values.\n\n### Read functions\n\n`yo` generates functions to read data from Cloud Spanner. The functions are generated based on index.\n\nNaming convention of generated functions is `FindXXXByYYY`. The XXX is table name and YYY is index name. XXX will be singular if the index is unique index, or plural if the index is not unique.\n\n\n**TODO**\n\n* Generated functions use `Query` only even if it is secondary index. Need a function to use `Read`.\n\n### Error handling\n\n`yo` wraps all errors as internal `yoError`. It has some methods for error handling.\n\n* `GRPCStatus()`\n   * This returns gRPC's `*status.Status`. It is intended by used from status google.golang.org/grpc/status package.\n* `DBTableName()`\n   * A table name where the error happens.\n* `NotFound()`\n   * A helper to check the error is NotFound.\n\nThe `yoError` inherits an original error from [google-cloud-go](https://github.com/GoogleCloudPlatform/google-cloud-go). It can still be used with `status.FromError` or `status.Code` to check status code of the error. So the typical error handling will be like:\n\n```golang\nresult, err := SomeFunction()\nif err != nil {\n\tcode := status.Code(err)\n\tif code == codes.InvalidArgument {\n\t\t// error handling for invalid argument\n\t}\n\t...\n\tpanic(\"unexpected\")\n}\n```\n\n## Templates for code generation\n\n`yo` uses Go [template](https://golang.org/pkg/text/template/) package to generate code. You can use your own template for code generation by using `--template-path` option.\n\n`yo` provides default templates and uses them when `--template-path` option is not specified. The templates exist in [templates](templates/) directory. The templates are embedded into `yo` binary.\n\n### Custom Template Quickstart\n\nThe following is a quick overview of copying the base templates contained in\nthe `yo` project's [`templates/`](templates) directory, editing to suit, and\nusing with `yo`:\n\n```sh\n# change to working project directory\n$ cd $GOPATH/src/path/to/my/project\n\n# create a template directory\n$ mkdir -p templates\n\n# copy yo templates\n$ cp \"$GOPATH/src/github.com/cloudspannerecosystem/yo/templates/*\" templates/\n\n# remove yo binary data\n$ rm templates/*.go\n\n# edit base templates\n$ vi templates/*.tpl.go\n\n# use with yo\n$ yo $SPANNER_PROJECT_NAME $SPANNER_INSTANCE_NAME $SPANNER_DATABASE_NAME -o models --template-path templates\n```\n\nSee the Custom Template example below for more information on adapting the base\ntemplates in the `yo` source tree for use within your own project.\n\n### Template files\n\n| Template File                  | Description                                           |\n|--------------------------------|-------------------------------------------------------|\n| `templates/type.go.tpl`        | Template for schema tables                            |\n| `templates/index.go.tpl`       | Template for schema indexes                           |\n| `templates/yo_db.go.tpl`       | Package level template generated once per package     |\n| `templates/yo_package.go.tpl`  | File header template generated once per file          |\n\n### Helper functions\n\n**This is not a stable feature**\n\n`yo` provides some helper functions which can be used in templates. Those are defined in [`generator/funcs.go`](generator/funcs.go). Those are not well documented and are likely to change.\n\n### Custom inflection rule file\n\n`yo` use inflection to convert singular or plural name each other.\nIf you want to add own rule, add `--inflection-rule-file` option with rule yaml file.\nrule yaml file sample is\n```\n- singular: person\n  plural: people\n- singular: live\n  plural: lives\n```\n\nSee https://github.com/jinzhu/inflection#register-rules for details.\n\n## Contributions\n\nPlease read the [contribution guidelines](CONTRIBUTING.md) before submitting\npull requests.\n\n## License\n\nCopyright 2018 Mercari, Inc.\n\nyo is released under the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudspannerecosystem%2Fyo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcloudspannerecosystem%2Fyo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudspannerecosystem%2Fyo/lists"}