Adding a Dependency
Add Protobuf module dependencies with easyp get and commit the resolved lockfile.
This guide demonstrates how to add a third-party or shared Protobuf module dependency to your EasyP project.
Add a module with easyp get
From the directory containing your protobuf.mod, run:
easyp get github.com/acme/weather
# Or select a tag or full Git commit:
easyp get github.com/acme/weather@v1.2.3get adds the selected module as a direct require, writes its transitive dependencies as // indirect, and updates protobuf.lock with exact commits and content hashes. A module inside a Git repository can be named by its full module path, such as github.com/acme/contracts/proto/user. A tag is optional; without one, EasyP locks the repository's current HEAD. Run the command separately in each local module directory that has its own protobuf.mod.
Add the required protobuf import to your .proto file, then review and commit both protobuf.mod and protobuf.lock.
The steps below show the equivalent manual manifest workflow.
Workflow Overview
- Declare Dependency: Add the target Git module identity to
protobuf.mod. Useimportstatements to reference files from that declared dependency. - Run Resolution: Execute
easyp mod tidyto compute the transitive dependency graph after editing the manifest manually. - Commit Lockfile: Review the updated
protobuf.modandprotobuf.lockfiles and commit them to version control.
Step 1: Declare the Dependency Manually
Open your module's protobuf.mod file and add the required module under the require block:
// proto/user/protobuf.mod
require (
github.com/googleapis/googleapis v1.5.0
github.com/acme/weather v1.2.3
)Then import a file provided by that dependency in your Protobuf source:
// proto/user/v1/user.proto
syntax = "proto3";
package user.v1;
import "google/type/datetime.proto";Step 2: Resolve Graph with easyp mod tidy
Run the easyp mod tidy command in your terminal:
easyp mod tidyWhat easyp mod tidy Does:
- Scans all
.protofiles in the module tree to identify activeimportstatements. - Downloads required module metadata from Git repositories.
- Computes Minimal Version Selection (MVS) for transitive dependencies.
- Appends transitive dependencies to
protobuf.modmarked with// indirect. - Generates or updates
protobuf.lockwith Git commit hashes and cryptographic content digests.
Git repositories using Buf or older EasyP configs
The consuming project still declares a Git source with require. The dependency repository may use another configuration format:
- EasyP v1
protobuf.mod: readsrootsandrequire. - Buf v2
buf.yaml: readsmodules[].pathas import roots. - Buf v1
buf.work.yaml: readsdirectories; a single-module v1buf.yamluses.. - Buf v1beta1
buf.yaml: readsbuild.roots, defaulting to.. - Older EasyP: reads
directdependencies from the oldprotobuf.modand localgenerate.inputs[].directory.rootplus Git inputs fromeasyp.yaml.
For an old EasyP dependency without a version on one of its Git requirements, mod tidy resolves the Git repository's HEAD and pins its commit in the v1 lock. No tag is required. The old EasyP source@<commit> form is also read transitively. Buf Registry deps are not Git sources, so declare an appropriate Git module in the consuming protobuf.mod when those imports are needed. Buf includes/excludes filters are not yet supported for Git dependency import roots and produce an explicit error.
Updated protobuf.mod:
require (
github.com/googleapis/googleapis v1.5.0
github.com/acme/weather v1.2.3
github.com/grpc-ecosystem/grpc-gateway v2.19.0 // indirect
)Step 3: Commit Changes
Always check both protobuf.mod and protobuf.lock into Git. This guarantees that all team members and CI pipelines build against the exact same schema versions:
git add protobuf.mod protobuf.lock
git commit -m "feat: add googleapis and weather dependencies"