Date: 23rd April, 2022
Title: Go Module with Microservices and Monorepo: Clear Dependencies with Ease of Development
Presented by @rytswd
Official Website: https://gocon.jp/2022spring/
Original Recording: https://youtu.be/jEdIXzvw_Ao
This repository contains all the materials used in my talk of "Go Module with Microservices and Monorepo: Clear Dependencies with Ease of Development" at Go Conference 2022 - Spring. There are mainly 3 demos, and it is made in a way that anyone can easily follow most of the steps on their own.
The details of each directory is as per below.
demos/1-basic
├── demo.sh
└── src
├── go.mod
├── go.sum
└── main.go
demo.sh
: A shell script made to run each command one by one when enter is pressed. You can follow the file content to run each line if you wish. The typing effect is achieved by/tools/demo-helper.sh
.demo-src/
: The abovedemo.sh
will create a new directorydemo-src
to start the demo from the empty directory.src/
: This directory has all the files as the result ofdemo.sh
run.go.mod
: List of module paths used in this Go module.go.sum
: List of direct and indirect dependencies, with cryptographic hashes for each.main.go
: Simple "Hello World" example, which has dependency to https://github.com/Code-Hex/Neo-cowsay.
demos/2-with-replace
├── demo.sh
└── src
├── brazil-farm
│ ├── coffee
│ │ └── coffee.go
│ └── go.mod
├── colombia-farm
│ ├── coffee
│ │ └── coffee.go
│ └── go.mod
├── uk-farm
│ ├── go.mod
│ └── milk
│ └── milk.go
└── gocon-cafe
├── go.mod
└── main.go
demo.sh
: A shell script made to run each command one by one when enter is pressed. You can follow the file content to run each line if you wish. The typing effect is achieved by/tools/demo-helper.sh
.demo-src/
: The abovedemo.sh
will create a new directorydemo-src
to start the demo from the empty directory.src/
: This directory has all the files as the result ofdemo.sh
run.brazil-farm/
: An example module, which defines a functionFruityCoffee()
.colombia-farm/
: An example module, which defines a functionDarkRoastedCoffee()
.uk-farm/
: An example module, which defines a functionWarmMilk()
.gocon-cafe/main.go
: Uses dependencies and runs 2 functions:MakeLatte()
- usesFruityCoffee()
andWarmMilk()
MakeFlatWhite()
- usesDarkRoastedCoffee()
andWarmMilk()
demos/3-all-in-one
├── demo.sh
└── src
├── brazil-farm
│ ├── coffee
│ │ └── coffee.go
│ └── go.mod
├── colombia-farm
│ ├── coffee
│ │ └── coffee.go
│ └── go.mod
├── uk-farm
│ ├── go.mod
│ └── milk
│ └── milk.go
├── gocon-cafe
│ ├── go.mod
│ ├── go.sum
│ └── main.go
└── gocon-restaurant
├── go.mod
├── go.sum
└── main.go
The directory structure is almost identical to demos/2-with-replace
. The key differences are:
demo.sh
does not copy files, simply runs some commands directly againstsrc
directory (and other setup along the way)- Each module (i.e.
brazil-farm
,colombia-farm
, anduk-farm
) have module path set togo.rytswd/...
gocon-cafe
uses module path reference based on Git commit, rather thanreplace
directivegocon-restaurant
is added first with module reference to the UK Farm commit of5f50441
- This allows
gocon-restaurant
to have its own dependency management
- This allows
- Go Modules Reference - Official documentation
- Life of a Go module by Jay Conrod, former Go team member
- Tutorial: Getting started with multi-module workspaces - Official tutorial
The Go gopher was designed by Renée French. Illustrations by tottie.
Thanks to the Go Conference Committee for allowing me to present 🥰