liveBook · Manning

Go module

As explained in gRPC Microservices in Go

A Go module is a versioned unit of Go source code and dependency metadata managed as a cohesive module.

A Go module is a versioned unit of Go source code and dependency metadata. It gives a microservice a VCS-backed identity, records its Go version in go.mod, and makes dependencies reproducible across development and deployment. section 4.2.2 section 3.3.1

Use a module to:

  • Initialize a service with a repository path, such as github.com/<username>/microservices/order, and establish its dependency structure. section 4.2.2
  • Publish generated gRPC service code from language-specific subfolders as independently addressable Go dependencies. section 3.3.1
  • Choose between a moving dependency such as @latest and a fixed version to reduce unexpected behavior when dependencies refresh. section 5.2
  • Keep end-to-end tests in a separate module with their own Docker Compose resources and database migrations. section 7.4.3

Versioning a payment client dependency

An Order service can add the Payment service with go get -u github.com/huseyinbabal/microservices-proto/golang/payment, or pin it with @v1.0.38. The resulting payment client can then call Create across the service boundary. section 5.2

├── golang                     #1
│   ├── order
│   │   ├── go.mod             #2
│   │   ├── go.sum             #3
│   │   ├── order.pb.go        #4
│   │   └── order_grpc.pb.go   #5
│   ├── payment
│   │   ├── go.mod
│   │   ├── go.sum
│   │   ├── payment.pb.go
│   │   └── payment_grpc.pb.go
│   └── shipping
│       ├── go.mod
│       ├── go.sum
│       ├── shipping.pb.go
│       └── shipping_grpc.pb.go
├── order
│   └── order.proto
├── payment
│   └── payment.proto
└── shipping
    └── shipping.proto

Inspect the repository layout to see how .proto definitions coexist with generated Go modules for order, payment, and shipping services. section 3.3.1

How gRPC Microservices in Go covers it

How deep it goes
Explains initialization, module paths, version selection, repository tags, and separate test modules, without detailing Go dependency resolution internals.
Examples
Uses order, payment, and shipping modules, versioned generated clients, go.mod initialization, and a separate e2e module.
What it assumes
Assumes a repository and Go project context, while teaching module initialization and dependency structure from the project setup step.
What you can do after
Apply it via go mod init and go get to create services, consume generated clients, pin versions, and isolate end-to-end tests.
How it connects
Connects Go modules with dependency management, gRPC, protocol buffers, Git tags, microservices, and end-to-end testing.

Also explained in

Compare how 4 books explain go module →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of gRPC Microservices in Go. The section links point to the parts of the book it draws on.