SlideShare a Scribd company logo
SEMVER AND MICROSERVICES
IN GO
by Viacheslav Poturaev
Golang meetup # 11
Agenda
• Microservices
• The problem
• Semantic versioning
• Breaking changes in GO
• Version constraints
• Dependency management in GO
• Glide
• Dep
Golang meetup # 11
Microservices
Big
PHP
Monolith
Nice
PHP
App
GO
API
GO
API
GO
API
GO
API
GO
API
GO
API
Team
Team
Team
TeamTeam
Team
Team
Team
TeamTeam
Team
Shared
libs and
clients
Golang meetup # 11
The problem
Golang meetup # 11
MAJOR.MINOR.PATCH
1. MAJOR version when you make incompatible API changes,
2. MINOR version when you add functionality in a backwards-compatible manner, and
3. PATCH version when you make backwards-compatible bug fixes.
Semantic Versioning
semver.org
X.0.0
• Breaking public changes
• MINOR and PATCH changes
X.Y.0
• New public features
• Deprecations
• PATCH changes
• New private features
• May be breaking for v0
X.Y.Z
• Non-breaking bug fixes
v1.0.0
1.0.0-alpha
1.0.0-rc1
2.1.5
v0.1.0
0.2.2-beta
1.0.0-beta+exp.sha.5114f85
v1.0.0-beta
Golang meetup # 11
Semantic Versioning
Application
Lib A
Lib B
Lib C
^1.0.0
2.0.0
master
1.2.4
1.2.3
1.2.2
2.1.0
2.0.0
1.0.0
Lib B
^2.0.0
^1.0.0
master
Golang meetup # 11
Breaking changes in GO
• Any changes in exported interfaces
• Removal or change of method of non-exported interface (that is implicitly exported)
• Removal, rename or field tag change of exported property in exported struct
• New exported property in exported structure
• Removing func/type/var/const at package scope
• Changing a function/method signature
Non-breaking changes
• Adding func/type/var/const at package scope
Breaking changes
Golang meetup # 11
Breaking changes in GO
package brittle // import "github.com/valuable/brittle"
import "errors"
type MyPublic struct{ Param string `json:"param" db:"param"` }
func (m MyPublic) DoWhatever(a MyPublic) (error, MyPublic) {
return Helper{"EN"}.GetError("ouch"), MyPublic{a.Param}
}
type Helper struct{ Lang string }
func (h Helper) GetError(text string) error { return errors.New(h.Lang + text) }
Golang meetup # 11
Breaking changes in GO
package extensible // import "github.com/valuable/extensible"
import "github.com/valuable/extensible/internal"
type iSomething interface {
DoWhatever(self iSomething) (error, iSomething)
GetParam() string
}
// New creates something
func New(param string) iSomething { return &myPrivate{Param: param} }
type myPrivate struct{ Param string `json:"param" db:"param"` }
func (m myPrivate) DoWhatever(a iSomething) (error, iSomething) {
return internal.Helper{"EN"}.GetError("ouch"), New(a.GetParam())
}
func (m myPrivate) GetParam() string { return m.Param }
Golang meetup # 11
Breaking changes in GO
package main
import (
"github.com/valuable/brittle"
"github.com/valuable/extensible"
)
type local struct {
brittle.MyPublic
Option string
}
func (l local) DoAnything() {}
func main() {
a := extensible.New("Hi")
a.DoWhatever(a)
b := brittle.MyPublic{"Hi"}
b.DoWhatever(b)
c := local{}
c.Param = "Hi"
c.Option = "yes"
c.DoWhatever(c.MyPublic)
c.DoAnything()
}
Golang meetup # 11
Breaking changes in GO
Safekeeping tips
• Don’t embed external structures and interfaces to avoid future collisions
• Avoid unkeyed struct literals for external structures
• Prefer temporary autogenerated mocks on external interfaces
• Don’t abuse reflect.DeepEqual against external structures
• Keep non-public exportables in internal folder
• Hide your public structs with constructors and interfaces
Golang meetup # 11
Version constraints
>= 1.2, < 3.0.0 || >= 4.2.3
Basic Comparisons
= equal (aliased to no operator)
!= not equal
> greater than
< less than
>= greater than or equal to
<= less than or equal to
Golang meetup # 11
Version constraints
Hyphen Range Comparisons
1.2 - 1.4.5 which is equivalent to >= 1.2, <= 1.4.5
2.3.4 - 4.5 which is equivalent to >= 2.3.4, <= 4.5
Wildcards In Comparisons
1.2.* is equivalent to >= 1.2.0, < 1.3.0
>= 1.2.* is equivalent to >= 1.2.0
<= 2.* is equivalent to <= 3
* is equivalent to >= 0.0.0
Golang meetup # 11
Version constraints
Tilde Range Comparisons
~1.2.3 is equivalent to >= 1.2.3, < 1.3.0
~1 is equivalent to >= 1, < 2
~2.3 is equivalent to >= 2.3, < 2.4
~1.2.x is equivalent to >= 1.2.0, < 1.3.0
~1.x is equivalent to >= 1, < 2
Caret Range Comparisons (Major)
^1.2.3 is equivalent to >= 1.2.3, < 2.0.0
^1.2.x is equivalent to >= 1.2.0, < 2.0.0
^2.3 is equivalent to >= 2.3, < 3
^2.x is equivalent to >= 2.0.0, < 3
Golang meetup # 11
Dependency management in GO
Go1
• Versioning by import path
• Imports with FQDN
• go get retrieves latest go1 or master reference
• Hard to make reproducible builds
• Import path supposed to not have breaking
changes after publishing
• Historically repo-level versioning was out of the
business
• Deps are globally stored under $GOPATH
The future
• Semantic versioning by release tags
• Imports with FQDN
• Dep requirements are defined in manifest file
by version constraints
• Build state is saved with lock file for
reproducible builds
• Fork-friendly
• Import path is not changed with breaking
change
• Deps are locally stored in local ./vendor
Golang meetup # 11
Glide
package: microfoorvice
ignore:
- github.com/skip/this/import
import:
- package: github.com/valuable/library
version: ^5.0.0
subpackages:
- config
- handler
- package: github.com/vektra/mockery/cmd/mockery
repo: https://github.com/codeactual/mockery.git
vcs: git
- package: github.com/tinylib/msgp
vcs: git
repo: ssh://git@gitlab.com/customforks/msgpack.git
version: ^1.0.0
subpackages:
- msgp
- parse
- printer
- gen
testImport:
- package: gopkg.in/check.v1
- package: github.com/tebeka/go2xunit
- package: github.com/alecthomas/gocyclo
Community
glide.yaml stores dev-defined constraints
glide.lock keeps snapshot of resolved constraints
glide install syncs vendor according to lock file
glide update resolves constraints with latest
available versions and saves to lock file
https://github.com/Masterminds/glide
v0.12.3
Golang meetup # 11
Dep
[[dependencies]]
name = "github.com/mailru/easyjson"
source = “gitlab.com/my-forks/easyjson”
version = "^1.0.0"
[[dependencies]]
name = “github.com/valuable/library“
version = "^2.0.0"
[[dependencies]]
name = "gopkg.in/urfave/cli.v2"
revision = "1b5ad735df034545a2ce018d348a814d406fc258"
A work in progress official tool
Gopkg.toml keeps user intent
Gopkg.lock keeps snapshot of resolved revisions
dep init set up a new project
dep ensure install the project's dependencies
dep ensure -update update the locked versions
of all dependencies
dep ensure github.com/mailru/easyjson:gitlab.com/my-forks/easyjson@^1.0.0
pre-alpha
https://github.com/golang/dep/
Golang meetup # 11
Thanks! Questions?

More Related Content

PDF
Flow based programming in golang
PPTX
GO Monitoring at lazada
PPTX
Feature Toggles
PPTX
Refresh your project vision with Report Portal
PPTX
TeamForge Overview Webinar (9/21)
PPTX
Feature toggles
PPTX
TeamForge Overview Webinar (10/5/16)
PDF
LF_APIStrat17_Super-Powered REST API Testing
Flow based programming in golang
GO Monitoring at lazada
Feature Toggles
Refresh your project vision with Report Portal
TeamForge Overview Webinar (9/21)
Feature toggles
TeamForge Overview Webinar (10/5/16)
LF_APIStrat17_Super-Powered REST API Testing

What's hot (20)

PPTX
Java 9 has these new features!
PPTX
Test armada integration with sauce labs
PDF
Overview of Gitlab usage
PDF
Performance testing for developers
PDF
Igor Bondarenko - Process organization of the development modules specific to...
PPTX
QA Fes 2016. Jacek Okrojek. Website performance from user perspective
PDF
Adventures with Microservices
PDF
Automation Testing Approach for Responsive Web Design
PPTX
Continuous Performance Testing with Taurus and Jmeter
PPTX
WiKi Based Automation Testing: Fitness & DevOps
PPTX
Semantic Versioning with GitVersion
PPT
Black Tea Testing #2 - Performance testing: why? when? how?
PPTX
SemVer, the whole story
PPTX
ATAGTR2017 Unified APM: The new age performance monitoring for production sys...
PDF
DCI presentation during OpenStack Montréal - 2018-06
PPTX
API Automation Testing Using RestAssured+Cucumber
PDF
Metrics by coda hale : to know your app’ health
PPTX
Quality automation at walmart scale
PPTX
Batch Processing with Mule 4
PDF
Hidden Dragons of CGO
Java 9 has these new features!
Test armada integration with sauce labs
Overview of Gitlab usage
Performance testing for developers
Igor Bondarenko - Process organization of the development modules specific to...
QA Fes 2016. Jacek Okrojek. Website performance from user perspective
Adventures with Microservices
Automation Testing Approach for Responsive Web Design
Continuous Performance Testing with Taurus and Jmeter
WiKi Based Automation Testing: Fitness & DevOps
Semantic Versioning with GitVersion
Black Tea Testing #2 - Performance testing: why? when? how?
SemVer, the whole story
ATAGTR2017 Unified APM: The new age performance monitoring for production sys...
DCI presentation during OpenStack Montréal - 2018-06
API Automation Testing Using RestAssured+Cucumber
Metrics by coda hale : to know your app’ health
Quality automation at walmart scale
Batch Processing with Mule 4
Hidden Dragons of CGO
Ad

Similar to SemVer and microservices in go (20)

PDF
Semantic versioning and microservices in GO
PDF
I don't know what I'm Doing: A newbie guide for Golang for DevOps
PPTX
Golang basics for Java developers - Part 1
PPTX
The GO Language : From Beginners to Gophers
PDF
Golang workshop
PPTX
golang_getting_started.pptx
PPTX
Golang iran - tutorial go programming language - Preliminary
PDF
Golang
PDF
Go 1.10 Release Party - PDX Go
PDF
Let's Go-lang
KEY
Google Go Overview
PPTX
Go. Why it goes
PPTX
Should i Go there
PDF
Inroduction to golang
PPTX
Next Generation Language Go
PPTX
Golang - Overview of Go (golang) Language
PPTX
A Very Brief Intro to Golang
PDF
Golang 101
PDF
LCA2014 - Introduction to Go
PDF
Golang勉強会
Semantic versioning and microservices in GO
I don't know what I'm Doing: A newbie guide for Golang for DevOps
Golang basics for Java developers - Part 1
The GO Language : From Beginners to Gophers
Golang workshop
golang_getting_started.pptx
Golang iran - tutorial go programming language - Preliminary
Golang
Go 1.10 Release Party - PDX Go
Let's Go-lang
Google Go Overview
Go. Why it goes
Should i Go there
Inroduction to golang
Next Generation Language Go
Golang - Overview of Go (golang) Language
A Very Brief Intro to Golang
Golang 101
LCA2014 - Introduction to Go
Golang勉強会
Ad

Recently uploaded (20)

PDF
Digital Logic Computer Design lecture notes
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPTX
OOP with Java - Java Introduction (Basics)
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPT
Project quality management in manufacturing
PPTX
Lecture Notes Electrical Wiring System Components
PPTX
Safety Seminar civil to be ensured for safe working.
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPT
introduction to datamining and warehousing
PPTX
Artificial Intelligence
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPT
Mechanical Engineering MATERIALS Selection
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
PPT on Performance Review to get promotions
PPTX
UNIT 4 Total Quality Management .pptx
Digital Logic Computer Design lecture notes
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
OOP with Java - Java Introduction (Basics)
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Project quality management in manufacturing
Lecture Notes Electrical Wiring System Components
Safety Seminar civil to be ensured for safe working.
R24 SURVEYING LAB MANUAL for civil enggi
UNIT-1 - COAL BASED THERMAL POWER PLANTS
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
bas. eng. economics group 4 presentation 1.pptx
introduction to datamining and warehousing
Artificial Intelligence
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Mechanical Engineering MATERIALS Selection
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPT on Performance Review to get promotions
UNIT 4 Total Quality Management .pptx

SemVer and microservices in go

  • 1. SEMVER AND MICROSERVICES IN GO by Viacheslav Poturaev
  • 2. Golang meetup # 11 Agenda • Microservices • The problem • Semantic versioning • Breaking changes in GO • Version constraints • Dependency management in GO • Glide • Dep
  • 3. Golang meetup # 11 Microservices Big PHP Monolith Nice PHP App GO API GO API GO API GO API GO API GO API Team Team Team TeamTeam Team Team Team TeamTeam Team Shared libs and clients
  • 4. Golang meetup # 11 The problem
  • 5. Golang meetup # 11 MAJOR.MINOR.PATCH 1. MAJOR version when you make incompatible API changes, 2. MINOR version when you add functionality in a backwards-compatible manner, and 3. PATCH version when you make backwards-compatible bug fixes. Semantic Versioning semver.org X.0.0 • Breaking public changes • MINOR and PATCH changes X.Y.0 • New public features • Deprecations • PATCH changes • New private features • May be breaking for v0 X.Y.Z • Non-breaking bug fixes v1.0.0 1.0.0-alpha 1.0.0-rc1 2.1.5 v0.1.0 0.2.2-beta 1.0.0-beta+exp.sha.5114f85 v1.0.0-beta
  • 6. Golang meetup # 11 Semantic Versioning Application Lib A Lib B Lib C ^1.0.0 2.0.0 master 1.2.4 1.2.3 1.2.2 2.1.0 2.0.0 1.0.0 Lib B ^2.0.0 ^1.0.0 master
  • 7. Golang meetup # 11 Breaking changes in GO • Any changes in exported interfaces • Removal or change of method of non-exported interface (that is implicitly exported) • Removal, rename or field tag change of exported property in exported struct • New exported property in exported structure • Removing func/type/var/const at package scope • Changing a function/method signature Non-breaking changes • Adding func/type/var/const at package scope Breaking changes
  • 8. Golang meetup # 11 Breaking changes in GO package brittle // import "github.com/valuable/brittle" import "errors" type MyPublic struct{ Param string `json:"param" db:"param"` } func (m MyPublic) DoWhatever(a MyPublic) (error, MyPublic) { return Helper{"EN"}.GetError("ouch"), MyPublic{a.Param} } type Helper struct{ Lang string } func (h Helper) GetError(text string) error { return errors.New(h.Lang + text) }
  • 9. Golang meetup # 11 Breaking changes in GO package extensible // import "github.com/valuable/extensible" import "github.com/valuable/extensible/internal" type iSomething interface { DoWhatever(self iSomething) (error, iSomething) GetParam() string } // New creates something func New(param string) iSomething { return &myPrivate{Param: param} } type myPrivate struct{ Param string `json:"param" db:"param"` } func (m myPrivate) DoWhatever(a iSomething) (error, iSomething) { return internal.Helper{"EN"}.GetError("ouch"), New(a.GetParam()) } func (m myPrivate) GetParam() string { return m.Param }
  • 10. Golang meetup # 11 Breaking changes in GO package main import ( "github.com/valuable/brittle" "github.com/valuable/extensible" ) type local struct { brittle.MyPublic Option string } func (l local) DoAnything() {} func main() { a := extensible.New("Hi") a.DoWhatever(a) b := brittle.MyPublic{"Hi"} b.DoWhatever(b) c := local{} c.Param = "Hi" c.Option = "yes" c.DoWhatever(c.MyPublic) c.DoAnything() }
  • 11. Golang meetup # 11 Breaking changes in GO Safekeeping tips • Don’t embed external structures and interfaces to avoid future collisions • Avoid unkeyed struct literals for external structures • Prefer temporary autogenerated mocks on external interfaces • Don’t abuse reflect.DeepEqual against external structures • Keep non-public exportables in internal folder • Hide your public structs with constructors and interfaces
  • 12. Golang meetup # 11 Version constraints >= 1.2, < 3.0.0 || >= 4.2.3 Basic Comparisons = equal (aliased to no operator) != not equal > greater than < less than >= greater than or equal to <= less than or equal to
  • 13. Golang meetup # 11 Version constraints Hyphen Range Comparisons 1.2 - 1.4.5 which is equivalent to >= 1.2, <= 1.4.5 2.3.4 - 4.5 which is equivalent to >= 2.3.4, <= 4.5 Wildcards In Comparisons 1.2.* is equivalent to >= 1.2.0, < 1.3.0 >= 1.2.* is equivalent to >= 1.2.0 <= 2.* is equivalent to <= 3 * is equivalent to >= 0.0.0
  • 14. Golang meetup # 11 Version constraints Tilde Range Comparisons ~1.2.3 is equivalent to >= 1.2.3, < 1.3.0 ~1 is equivalent to >= 1, < 2 ~2.3 is equivalent to >= 2.3, < 2.4 ~1.2.x is equivalent to >= 1.2.0, < 1.3.0 ~1.x is equivalent to >= 1, < 2 Caret Range Comparisons (Major) ^1.2.3 is equivalent to >= 1.2.3, < 2.0.0 ^1.2.x is equivalent to >= 1.2.0, < 2.0.0 ^2.3 is equivalent to >= 2.3, < 3 ^2.x is equivalent to >= 2.0.0, < 3
  • 15. Golang meetup # 11 Dependency management in GO Go1 • Versioning by import path • Imports with FQDN • go get retrieves latest go1 or master reference • Hard to make reproducible builds • Import path supposed to not have breaking changes after publishing • Historically repo-level versioning was out of the business • Deps are globally stored under $GOPATH The future • Semantic versioning by release tags • Imports with FQDN • Dep requirements are defined in manifest file by version constraints • Build state is saved with lock file for reproducible builds • Fork-friendly • Import path is not changed with breaking change • Deps are locally stored in local ./vendor
  • 16. Golang meetup # 11 Glide package: microfoorvice ignore: - github.com/skip/this/import import: - package: github.com/valuable/library version: ^5.0.0 subpackages: - config - handler - package: github.com/vektra/mockery/cmd/mockery repo: https://github.com/codeactual/mockery.git vcs: git - package: github.com/tinylib/msgp vcs: git repo: ssh://git@gitlab.com/customforks/msgpack.git version: ^1.0.0 subpackages: - msgp - parse - printer - gen testImport: - package: gopkg.in/check.v1 - package: github.com/tebeka/go2xunit - package: github.com/alecthomas/gocyclo Community glide.yaml stores dev-defined constraints glide.lock keeps snapshot of resolved constraints glide install syncs vendor according to lock file glide update resolves constraints with latest available versions and saves to lock file https://github.com/Masterminds/glide v0.12.3
  • 17. Golang meetup # 11 Dep [[dependencies]] name = "github.com/mailru/easyjson" source = “gitlab.com/my-forks/easyjson” version = "^1.0.0" [[dependencies]] name = “github.com/valuable/library“ version = "^2.0.0" [[dependencies]] name = "gopkg.in/urfave/cli.v2" revision = "1b5ad735df034545a2ce018d348a814d406fc258" A work in progress official tool Gopkg.toml keeps user intent Gopkg.lock keeps snapshot of resolved revisions dep init set up a new project dep ensure install the project's dependencies dep ensure -update update the locked versions of all dependencies dep ensure github.com/mailru/easyjson:gitlab.com/my-forks/easyjson@^1.0.0 pre-alpha https://github.com/golang/dep/
  • 18. Golang meetup # 11 Thanks! Questions?