Open-source project
googleapis/go-genproto avatar
googleapis/go-genproto

go-genproto and the generated Go code behind Google APIs

Generated code for Google Cloud client libraries.

630 stars203 forksGoApache-2.0

At a glance

What is it?
go-genproto is the module that holds the generated Go types and gRPC code for Google's APIs, split into per-service submodules so that a project depending on one service does not pull in the rest. The interesting engineering is the split and the aliasing of well-known types, and the interesting caveat is that the repository labels itself experimental and says the package structure is subject to change.
Who is it for?
go-genproto is a good fit for a Go service calling Google Cloud APIs, especially one that needs a specific service's types without taking on the whole API surface, because the per-service submodules keep the dependency graph small and the well-known types are aliased to a single canonical module.
Can I use it commercially?
Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 4 days ago.
What is it written in?
Mainly Go, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on October 23, 2026, and from our analysis. They are not legal advice.

Editorial analysis

What the module actually contains

The repository description is minimal: generated code for Google Cloud client libraries. The README fills in a little more, saying the repository contains the generated Go packages for common protocol buffer types, and the generated gRPC code necessary for interacting with Google's gRPC APIs.

The installation instruction is a single command:

bash
go get google.golang.org/genproto/...

Note the trailing ellipsis. It is fetching everything under the module path, which is exactly the mistake the project later warns about, because the module is now split into submodules and pulling the root means pulling every service.

The provenance is documented rather than implied. The sources for the proto files used in the repository are the googleapis/googleapis repository, and the packages here contain types specifically for interacting with Google APIs.

The licence is Apache-2.0, and the repository carries a LICENSE file, a SECURITY.md, a CONTRIBUTING.md, a CODE_OF_CONDUCT.md and a RELEASING.md, which tells you the release process is written down somewhere.

The audience is a Go developer who has to speak a Google API's protocol buffer dialect and wants the generated types without hand-rolling them, and the more common audience is a dependency of the hand-written client libraries rather than a direct choice.

The submodule split and the 2024 import deadline

The most operationally important line in the README is a warning with a date on it.

It reads that new submodules were introduced on 2023-05-26, and that you should upgrade before 2024-03-01 to avoid ambiguous import errors with google.golang.org/genproto, with a link to issue 1015 for more information.

That is a specific and dated migration, and it is worth understanding what it did. Before the split, the root module held the generated code for every service, so importing anything from it brought in everything. After the split, each service or group of services is its own Go module with its own version, and the root module exists only to hold the shared pieces and to declare the dependencies.

The go.mod in the repository root shows the shape of the result. It requires the individual cloud.google.com/go modules for the services, among them aiplatform, appengine, bigquery, cloudtasks, container, containeranalysis, dataflow, dataproc, documentai, domains, iam, language, logging, longrunning, recommender, securitycenter, servicedirectory, spanner, video and videointelligence. Then it requires the two genproto submodules, googleapis/api and googleapis/rpc, both pinned to the same pseudo-version, and grpc and protobuf.

That is the whole point of the design. A project that only calls BigQuery should end up with the bigquery module and the shared api and rpc submodules, not the generated code for every Google service that has ever existed.

Type aliases forward the well-known types instead of copying them

The second piece of the mechanism is how the historically awkward part of the module is handled.

The README says that historically the packages in the protobuf directory used to contain generated code for certain well-known types hosted by google/protobuf. Those types are now hosted by the google.golang.org/protobuf module, and type aliases are used to forward declarations in this module over to declarations in the protobuf module.

That is the right mechanism, and the reason is that a Go type can only have one identity. If two modules both declared a message type with the same name, a value produced by one and passed to the other would be a type mismatch, and the compiler would reject it. Duplicating the well-known types would have created exactly that problem. A type alias declares a new name for an existing type, so the identity is preserved and the packages remain interchangeable.

The practical effect for a caller is that the older import path still compiles and still works, while the canonical definition lives in one place. A service package that refers to a timestamp still refers to the same timestamp type as the protobuf module, and the grpc and protobuf modules are the ones in the go.mod alongside it.

There is also a go.work file and a go.work.sum in the repository root, which is the workspace mechanism for developing several of these modules at once, and a regen.txt file, which is the record of what the code generation produces.

The experimental label, and what it means for a dependency

The README is blunt about the status. It says the repository is currently experimental and that the structure of the contained packages is subject to change, and it tells the reader to consult the original source repositories, listed below, to find out the status of each protocol buffer's associated service.

That sentence is a pointer to where the real status lives. A protocol buffer service is defined upstream, in the googleapis repository, and the service's own documentation and release state are recorded there. The Go package in this repository is a projection of that definition, and a projection can be regenerated, versioned independently or held back.

For a direct dependency, the practical reading is that you should expect to touch your imports again when the layout moves, exactly as the 2024 deadline asked you to. The cost of that is not the module path but the churn in your go.mod, and the go.mod itself shows how much churn: the submodules are pinned to pseudo-versions with a commit hash and a timestamp, 0.0.0-20261012220534-4341edf3f941, which is the standard way to pin an unversioned module to a specific commit.

The alternative, and the one most Go developers end up choosing, is the hand-written client libraries. The root go.mod of this repository requires a long list of cloud.google.com/go modules, and those libraries are the ones that depend on these generated packages, so a project that only needs a client ends up with the same generated code underneath and a stable API on top of it. The generated modules are what you reach for when you need the types themselves, for instance a proto message that no hand-written client exposes.

Go version, toolchain and the shape of the build

The go.mod is short and tells you the toolchain requirements plainly. The module is google.golang.org/genproto, and it declares go 1.26.0, which is a high floor and worth checking against the Go version your build pipeline runs.

The dependency list is short too, with a few indirect requirements for the standard library pieces: golang.org/x/net, golang.org/x/sys and golang.org/x/text.

The repository root is small for a codebase of this size: .github, CODE_OF_CONDUCT.md, CONTRIBUTING.md, LICENSE, README.md, RELEASING.md, SECURITY.md, go.mod, go.sum, go.work, go.work.sum, and then the directories that matter, googleapis/, internal/, protobuf/, plus regen.txt.

That directory listing is the module map. googleapis/ holds the generated code derived from the googleapis repository, protobuf/ holds the aliased well-known types, and internal/ holds the code generation machinery that turns the upstream proto files into Go. The regen.txt file at the root sits alongside as the record of the generated output.

The .github directory, combined with RELEASING.md and the release-please style configuration files in the root, indicates that releases are automated. For a repository whose entire output is generated code, that is the correct arrangement, because the only thing that should require human attention is the schedule.

Editorial conclusion

go-genproto is a good fit for a Go service calling Google Cloud APIs, especially one that needs a specific service's types without taking on the whole API surface, because the per-service submodules keep the dependency graph small and the well-known types are aliased to a single canonical module. It is a poor fit if you want a stable API, since the repository describes itself as experimental with a structure subject to change, and a poor fit if you are starting a new project, because the hand-written client libraries are the intended entry point. Before adopting, check whether the cloud.google.com/go module for the service you need already depends on the right submodule, and read the module layout rather than importing the root, because the root pulls in every service at once.

Frequently asked questions

How do I install the go-genproto packages?

The README gives go get google.golang.org/genproto/... . Note the trailing ellipsis fetches every service, and the same README warns that new submodules were introduced on 2023-05-26 and that you should upgrade before 2024-03-01 to avoid ambiguous import errors.

What is the difference between the root genproto module and its submodules?

The root module holds the shared pieces and declares dependencies on the per-service submodules, such as google.golang.org/genproto/googleapis/api and google.golang.org/genproto/googleapis/rpc, both pinned to the same commit in the go.mod. Depending on a single submodule keeps the dependency graph to the services you actually use.

How are the well-known protobuf types handled in go-genproto?

The types that used to live in the protobuf directory are now hosted by the google.golang.org/protobuf module, and type aliases forward the declarations in this module over to the ones there, so a single Go type identity is preserved across both import paths.

Is go-genproto stable?

The README states that the repository is currently experimental and that the structure of the contained packages is subject to change, and it directs readers to the original source repositories to find out the status of each protocol buffer's associated service.

Official sources

  1. googleapis/go-genproto on GitHub
  2. Issues
  3. License: Apache-2.0
  4. Project website
  5. README
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/googleapis-go-genproto.svg)](https://hysenlabs.com/projects/googleapis-go-genproto)

Was this useful?