SlideShare a Scribd company logo
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
Refactoring to modules
Why, How and Everything Else I Can Fit In 45
Minutes…
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
A Big thanks to our hosts of today
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
https://jfrog.com/shownotes
shownotes
Slides Links Comments
& Ratings
Raffle
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
Who am I?
• Developer Advocate
• Passionate about Serverless,
Containers, and all things
Cloud
• I love dadjokes, cheesecake
and Go
@LeonStigter
Leon Stigter, Developer Advocate
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
Dadjokes?
What happens when you hold a Unix terminal to your ear?
You can hear the C
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
Let’s travel back in time…
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
When did you start with Go?
Let’s turn to the audience for a poll…
1.0
2012
1.2
2013
1.5
2015
1.8
2017
1.11
2018
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
A quick history of go
Go 1.0
First major
milestone as a
long term
stable release
2012 2015
Go 1.5
First release to
no longer use C
(except for cgo)
2017
Go 1.8
Introduction of
Go plugins
2018
Go 1.11
This is where
the magic is! (at
least for this
talk J)
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
Dependency Management…
So what is that magic?
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
“Tis impossible to be sure of anything
but Death and Taxes”
- Christopher Bullock
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
At JFROG, we really like pipelines and promotions
CI
SERVER
Integration System Testing
If quality
requirments are hit
If quality
requirments are hit
If quality
requirments are hit
Staging
- Quality gates -
Production
1 2 3 4
*
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
At jfrog, we absolutely love Immutable and repeatable builds
The best way to guarantee issues is force push
Immutable dependencies
Who doesn’t remember left-pad with Node.js?
Lost Dependencies
Even build when GitHub is down!?
Internet Issues
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
Show me something already!
¯_(ツ)_/¯
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
Recapping, gocenter is…
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
Discovery
Go
Notifier
Go
Processor
Go
Validator
Go
UI Backend
Go
UI
Node.js
Built out of a few microservices
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
Start with the why…
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
In Go, We had a
Problem…
Source: Go at Google https://www.infoq.com/presentations/Go-Google
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
One easy solution…?
Dependencies are sources!
Remote imports are in VCS
Dump everything into a single folder
Compile…
Profit!!
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
• Which dependencies I use?
• Which dependencies you
used?
• Which dependencies I should
use?
• Which code I’m editing right
now?
• What is going on?!
But… how do I know…
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
Vendoring – the worst kind of forking
“Copy all of the files at some version from one version
control repository and paste them into a different version
control repository”
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
• History, branch, and tag information
is lost
• Pulling updates is impossible
• It invites modification, divergence,
and bad fork
• It wastes space
• Good luck finding which version of
the code you forked
But what is wrong with vendoring?
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
Build your own dependency manager…
“It’s not the role of the tooling provided by
the language to dictate how you manage
your code (...)”
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
• Working in project directories
• Local cache for dependencies
• Version declarations
• Conflict resolution
Go dep – Proper dependency management?
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
Who is using Go modules?
Let’s turn to the audience for another poll…
Yes No
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
Module
A module is a collection of
related Go packages that
are versioned together as a
single unit.
Let’s go over some definitions
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
Sources
A module is a tree
(directory) of Go source
files with a go.mod file in
the root directory.
Let’s go over some definitions
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
Version Control
Most often, a single version-
control repository
corresponds exactly to a
single module
Let’s go over some definitions
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
Set the environment variable
GO111MODULE to ON
Use go outside of your
$GOPATH
Using go modules
1 2
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
mkdir mymodule
cd mymodule
go mod init github.com/retgits/mymodule
Creating a module
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
• Import dependencies from Gopkg.lock
go mod init <module path>
• Remove unnecessary imports and add indirect imports
go mod tidy
• Delete the vendor folder
rm –rf vendor/
• Delete Gopkg files
rm Gopkg.*
Moving from DEP to modules
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
Go.mod by any other name…
Would probably not work…
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
module github.com/retgits/mymodule
go 1.12
require (
github.com/naoina/go-stringutil v0.1.0
github.com/some/dependency v1.2.3
github.com/google/go-github/v25 v25.0.1
)
replace github.com/some/dependency github.com/retgits/dependency
versioning
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
module github.com/retgits/mymodule
go 1.12
require (
github.com/naoina/go-stringutil v0.1.0
github.com/some/dependency v1.2.3
github.com/google/go-github/v25 v25.0.1
)
replace github.com/some/dependency github.com/retgits/dependency
Replacing packages
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
module github.com/retgits/mymodule
go 1.12
require (
github.com/naoina/go-stringutil v0.1.0
github.com/some/dependency v1.2.3
github.com/google/go-github/v25 v25.0.1
)
replace github.com/some/dependency ../../Downloads/dependency
Works with local folders too!
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
• You can create the vendor folder
go mod vendor
• You can use the vendor folder during builds
go build –mod=vendor
This does mean you need to have all dependencies
listed in your go.mod file
But I kinda like the vendor folder?
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
• If you run `go mod vendor`, the `vendor` directory it creates should
reflect your `replace` directives. (That is: it should put the
replacement content in the `vendor` directory rather than the
original module content.)
• But if as you say, `-mod=vendor` bypasses go.mod that makes
sense.
• So does `-mod=vendor` require you to have vendored all your
dependencies? (edited)
• Yes. If you have a complete `go.mod`, `go mod vendor` will do that
for you (as Bryan said, including taking into account `replace`
statements).
But I kinda like the vendor folder?
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
Houston… I think I lost my module?
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
The <module>@v<version> construct should be immutable
That means that
github.com/retgits/checkiday/@v/v1.0.0
Should forever be the same…
Modules are immutable
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
But are they really?
”Friends don’t let friends do git push -f”
- Aaron Schlesinger
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
Using the goproxy variable
export GOPROXY=https://myawesomeproxy.com
go get github.com/retgits/checkiday
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
Keeping modules
Immediate access, not shared, can be wiped…
Local cache ($GOPATH/pkg/mod)
Fast access, requires infra, shared across devs
Organizational cache (private proxy)
Highly available, CDN, no infra, free
Public cache (public proxy)
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
And also faster builds…
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
Before modules
go get github.com/project-flogo/cli
git clone https://github.com/project-flogo/cli
<build module locally>
With modules
go get github.com/project-flogo/cli
GET github.com/project-flogo/cli/@v/list
GET github.com/project-flogo/cli/@v/v1.0.0.mod
GET github.com/project-flogo/cli/@v/v1.0.0.zip
Go get my module!
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
• If you haven’t, start with Go modules:
GO111MODULE=on
• Start working outside of your $GOPATH
• Use a public proxy server for immutable Go modules (like
GoCenter.io)
• Think about running your own proxy server (like Project
Athens)
Final thoughts
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
There’s one more thing…
But before I go…
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
What is a 5* module for you?
We talked about modules a bit…
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
• https://jfrog.com/shownotes
• @JFrog
• #GoLang
• https://gocenter.io
• @LeonStigter
Twitter, ads, and Q&a
@JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter
Thank you!

More Related Content

Similar to Refactoring to Modules - Why, How and Everything Else I Can Fit In 45 Minutes…

iTHome Gopher Day 2017: What can Golang do? (Using project 52 as examples)
iTHome Gopher Day 2017: What can Golang do?  (Using project 52 as examples)iTHome Gopher Day 2017: What can Golang do?  (Using project 52 as examples)
iTHome Gopher Day 2017: What can Golang do? (Using project 52 as examples)
Evan Lin
 
Build and Deploy a Python Web App to Amazon in 30 Mins
Build and Deploy a Python Web App to Amazon in 30 MinsBuild and Deploy a Python Web App to Amazon in 30 Mins
Build and Deploy a Python Web App to Amazon in 30 Mins
Jeff Hull
 
Gianluca Esposito - It's time to go Native! (with JavaScript and React Native...
Gianluca Esposito - It's time to go Native! (with JavaScript and React Native...Gianluca Esposito - It's time to go Native! (with JavaScript and React Native...
Gianluca Esposito - It's time to go Native! (with JavaScript and React Native...
Codemotion
 
The what, how and why of scaling git repositories
The what, how and why of scaling git repositoriesThe what, how and why of scaling git repositories
The what, how and why of scaling git repositories
Johan Abildskov
 
Best practices for joomla extensions developers
Best practices for joomla extensions developersBest practices for joomla extensions developers
Best practices for joomla extensions developers
Francesco Abeni
 
jQueryTO: State of jQuery March 2013
jQueryTO: State of jQuery March 2013jQueryTO: State of jQuery March 2013
jQueryTO: State of jQuery March 2013dmethvin
 
Selendroid in Action
Selendroid in ActionSelendroid in Action
Selendroid in Action
Dominik Dary
 
How to plan and define your CI-CD pipeline
How to plan and define your CI-CD pipelineHow to plan and define your CI-CD pipeline
How to plan and define your CI-CD pipeline
ElasTest Project
 
Dagger 2, 2 years later
Dagger 2, 2 years laterDagger 2, 2 years later
Dagger 2, 2 years later
K. Matthew Dupree
 
05092019 The Battle of the IDEs by Ko Turk at the AlmereJUG / Conspect
05092019 The Battle of the IDEs by Ko Turk at the AlmereJUG / Conspect05092019 The Battle of the IDEs by Ko Turk at the AlmereJUG / Conspect
05092019 The Battle of the IDEs by Ko Turk at the AlmereJUG / Conspect
Ko Turk
 
jsDay - Javascript as a programming language
jsDay - Javascript as a programming languagejsDay - Javascript as a programming language
jsDay - Javascript as a programming language
Marco Cedaro
 
Engage 2018 adm04 The lazy admin wins
Engage 2018   adm04 The lazy admin winsEngage 2018   adm04 The lazy admin wins
Engage 2018 adm04 The lazy admin wins
Factor-y S.r.l.
 
Engage 2018 adm04 - The lazy admin wins
Engage 2018   adm04 - The lazy admin winsEngage 2018   adm04 - The lazy admin wins
Engage 2018 adm04 - The lazy admin wins
Matteo Bisi
 
Magento 2 Performance: Every Second Counts
Magento 2 Performance: Every Second CountsMagento 2 Performance: Every Second Counts
Magento 2 Performance: Every Second Counts
Joshua Warren
 
Get Struck By Lightning
Get Struck By LightningGet Struck By Lightning
Get Struck By Lightning
Mustafa Jhabuawala
 
Juliette Reinders Folmer - Promote your open source project with GitHub Pages...
Juliette Reinders Folmer - Promote your open source project with GitHub Pages...Juliette Reinders Folmer - Promote your open source project with GitHub Pages...
Juliette Reinders Folmer - Promote your open source project with GitHub Pages...
Codemotion
 
How I become Go GDE
How I become Go GDEHow I become Go GDE
How I become Go GDE
Evan Lin
 
Modernisation of legacy PHP applications using Symfony2 - PHP Northeast Confe...
Modernisation of legacy PHP applications using Symfony2 - PHP Northeast Confe...Modernisation of legacy PHP applications using Symfony2 - PHP Northeast Confe...
Modernisation of legacy PHP applications using Symfony2 - PHP Northeast Confe...
Fabrice Bernhard
 
State of jQuery June 2013 - Portland
State of jQuery June 2013 - PortlandState of jQuery June 2013 - Portland
State of jQuery June 2013 - Portland
dmethvin
 
Working with Git
Working with GitWorking with Git
Working with Git
Tony Hillerson
 

Similar to Refactoring to Modules - Why, How and Everything Else I Can Fit In 45 Minutes… (20)

iTHome Gopher Day 2017: What can Golang do? (Using project 52 as examples)
iTHome Gopher Day 2017: What can Golang do?  (Using project 52 as examples)iTHome Gopher Day 2017: What can Golang do?  (Using project 52 as examples)
iTHome Gopher Day 2017: What can Golang do? (Using project 52 as examples)
 
Build and Deploy a Python Web App to Amazon in 30 Mins
Build and Deploy a Python Web App to Amazon in 30 MinsBuild and Deploy a Python Web App to Amazon in 30 Mins
Build and Deploy a Python Web App to Amazon in 30 Mins
 
Gianluca Esposito - It's time to go Native! (with JavaScript and React Native...
Gianluca Esposito - It's time to go Native! (with JavaScript and React Native...Gianluca Esposito - It's time to go Native! (with JavaScript and React Native...
Gianluca Esposito - It's time to go Native! (with JavaScript and React Native...
 
The what, how and why of scaling git repositories
The what, how and why of scaling git repositoriesThe what, how and why of scaling git repositories
The what, how and why of scaling git repositories
 
Best practices for joomla extensions developers
Best practices for joomla extensions developersBest practices for joomla extensions developers
Best practices for joomla extensions developers
 
jQueryTO: State of jQuery March 2013
jQueryTO: State of jQuery March 2013jQueryTO: State of jQuery March 2013
jQueryTO: State of jQuery March 2013
 
Selendroid in Action
Selendroid in ActionSelendroid in Action
Selendroid in Action
 
How to plan and define your CI-CD pipeline
How to plan and define your CI-CD pipelineHow to plan and define your CI-CD pipeline
How to plan and define your CI-CD pipeline
 
Dagger 2, 2 years later
Dagger 2, 2 years laterDagger 2, 2 years later
Dagger 2, 2 years later
 
05092019 The Battle of the IDEs by Ko Turk at the AlmereJUG / Conspect
05092019 The Battle of the IDEs by Ko Turk at the AlmereJUG / Conspect05092019 The Battle of the IDEs by Ko Turk at the AlmereJUG / Conspect
05092019 The Battle of the IDEs by Ko Turk at the AlmereJUG / Conspect
 
jsDay - Javascript as a programming language
jsDay - Javascript as a programming languagejsDay - Javascript as a programming language
jsDay - Javascript as a programming language
 
Engage 2018 adm04 The lazy admin wins
Engage 2018   adm04 The lazy admin winsEngage 2018   adm04 The lazy admin wins
Engage 2018 adm04 The lazy admin wins
 
Engage 2018 adm04 - The lazy admin wins
Engage 2018   adm04 - The lazy admin winsEngage 2018   adm04 - The lazy admin wins
Engage 2018 adm04 - The lazy admin wins
 
Magento 2 Performance: Every Second Counts
Magento 2 Performance: Every Second CountsMagento 2 Performance: Every Second Counts
Magento 2 Performance: Every Second Counts
 
Get Struck By Lightning
Get Struck By LightningGet Struck By Lightning
Get Struck By Lightning
 
Juliette Reinders Folmer - Promote your open source project with GitHub Pages...
Juliette Reinders Folmer - Promote your open source project with GitHub Pages...Juliette Reinders Folmer - Promote your open source project with GitHub Pages...
Juliette Reinders Folmer - Promote your open source project with GitHub Pages...
 
How I become Go GDE
How I become Go GDEHow I become Go GDE
How I become Go GDE
 
Modernisation of legacy PHP applications using Symfony2 - PHP Northeast Confe...
Modernisation of legacy PHP applications using Symfony2 - PHP Northeast Confe...Modernisation of legacy PHP applications using Symfony2 - PHP Northeast Confe...
Modernisation of legacy PHP applications using Symfony2 - PHP Northeast Confe...
 
State of jQuery June 2013 - Portland
State of jQuery June 2013 - PortlandState of jQuery June 2013 - Portland
State of jQuery June 2013 - Portland
 
Working with Git
Working with GitWorking with Git
Working with Git
 

More from Leon Stigter

Thinking Stateful Serverless
Thinking Stateful ServerlessThinking Stateful Serverless
Thinking Stateful Serverless
Leon Stigter
 
Test driving event-driven apps on kubernetes with kind, tekton, and knative
Test driving event-driven apps on kubernetes with kind, tekton, and knativeTest driving event-driven apps on kubernetes with kind, tekton, and knative
Test driving event-driven apps on kubernetes with kind, tekton, and knative
Leon Stigter
 
Building Event-Driven Workflows with Knative and Tekton
Building Event-Driven Workflows with Knative and TektonBuilding Event-Driven Workflows with Knative and Tekton
Building Event-Driven Workflows with Knative and Tekton
Leon Stigter
 
Data Driven Decisions in DevOps
Data Driven Decisions in DevOpsData Driven Decisions in DevOps
Data Driven Decisions in DevOps
Leon Stigter
 
Every Talk Has To Be Unique @ DevRel Meetup
Every Talk Has To Be Unique @ DevRel Meetup Every Talk Has To Be Unique @ DevRel Meetup
Every Talk Has To Be Unique @ DevRel Meetup
Leon Stigter
 
Continuous Verification in a Serverless World
Continuous Verification in a Serverless WorldContinuous Verification in a Serverless World
Continuous Verification in a Serverless World
Leon Stigter
 
Continuous Verification in a Serverless World
Continuous Verification in a Serverless WorldContinuous Verification in a Serverless World
Continuous Verification in a Serverless World
Leon Stigter
 
Trusting Your Ingredients @DevOpsDays Columbus 2019
Trusting Your Ingredients @DevOpsDays Columbus 2019Trusting Your Ingredients @DevOpsDays Columbus 2019
Trusting Your Ingredients @DevOpsDays Columbus 2019
Leon Stigter
 
Persistence is futile (or is it?) - How to Manage, Version, and Promote Docke...
Persistence is futile (or is it?) - How to Manage, Version, and Promote Docke...Persistence is futile (or is it?) - How to Manage, Version, and Promote Docke...
Persistence is futile (or is it?) - How to Manage, Version, and Promote Docke...
Leon Stigter
 
Data Driven DevOps
Data Driven DevOpsData Driven DevOps
Data Driven DevOps
Leon Stigter
 
DevOps Theory vs. Practice: A Song of Ice and Tire Fire
DevOps Theory vs. Practice: A Song of Ice and Tire FireDevOps Theory vs. Practice: A Song of Ice and Tire Fire
DevOps Theory vs. Practice: A Song of Ice and Tire Fire
Leon Stigter
 
The Art of Deploying Artifacts to Production With Confidence
The Art of Deploying Artifacts to Production With ConfidenceThe Art of Deploying Artifacts to Production With Confidence
The Art of Deploying Artifacts to Production With Confidence
Leon Stigter
 
Project Flogo: Serverless Integration, Powered by Flogo and Lambda
Project Flogo: Serverless Integration, Powered by Flogo and LambdaProject Flogo: Serverless Integration, Powered by Flogo and Lambda
Project Flogo: Serverless Integration, Powered by Flogo and Lambda
Leon Stigter
 
Project Flogo: An Event-Driven Stack for the Enterprise
Project Flogo: An Event-Driven Stack for the EnterpriseProject Flogo: An Event-Driven Stack for the Enterprise
Project Flogo: An Event-Driven Stack for the Enterprise
Leon Stigter
 
The Road to a Cloud-First Enterprise
The Road to a Cloud-First EnterpriseThe Road to a Cloud-First Enterprise
The Road to a Cloud-First Enterprise
Leon Stigter
 
Building serverless apps with Go & SAM
Building serverless apps with Go & SAMBuilding serverless apps with Go & SAM
Building serverless apps with Go & SAM
Leon Stigter
 

More from Leon Stigter (16)

Thinking Stateful Serverless
Thinking Stateful ServerlessThinking Stateful Serverless
Thinking Stateful Serverless
 
Test driving event-driven apps on kubernetes with kind, tekton, and knative
Test driving event-driven apps on kubernetes with kind, tekton, and knativeTest driving event-driven apps on kubernetes with kind, tekton, and knative
Test driving event-driven apps on kubernetes with kind, tekton, and knative
 
Building Event-Driven Workflows with Knative and Tekton
Building Event-Driven Workflows with Knative and TektonBuilding Event-Driven Workflows with Knative and Tekton
Building Event-Driven Workflows with Knative and Tekton
 
Data Driven Decisions in DevOps
Data Driven Decisions in DevOpsData Driven Decisions in DevOps
Data Driven Decisions in DevOps
 
Every Talk Has To Be Unique @ DevRel Meetup
Every Talk Has To Be Unique @ DevRel Meetup Every Talk Has To Be Unique @ DevRel Meetup
Every Talk Has To Be Unique @ DevRel Meetup
 
Continuous Verification in a Serverless World
Continuous Verification in a Serverless WorldContinuous Verification in a Serverless World
Continuous Verification in a Serverless World
 
Continuous Verification in a Serverless World
Continuous Verification in a Serverless WorldContinuous Verification in a Serverless World
Continuous Verification in a Serverless World
 
Trusting Your Ingredients @DevOpsDays Columbus 2019
Trusting Your Ingredients @DevOpsDays Columbus 2019Trusting Your Ingredients @DevOpsDays Columbus 2019
Trusting Your Ingredients @DevOpsDays Columbus 2019
 
Persistence is futile (or is it?) - How to Manage, Version, and Promote Docke...
Persistence is futile (or is it?) - How to Manage, Version, and Promote Docke...Persistence is futile (or is it?) - How to Manage, Version, and Promote Docke...
Persistence is futile (or is it?) - How to Manage, Version, and Promote Docke...
 
Data Driven DevOps
Data Driven DevOpsData Driven DevOps
Data Driven DevOps
 
DevOps Theory vs. Practice: A Song of Ice and Tire Fire
DevOps Theory vs. Practice: A Song of Ice and Tire FireDevOps Theory vs. Practice: A Song of Ice and Tire Fire
DevOps Theory vs. Practice: A Song of Ice and Tire Fire
 
The Art of Deploying Artifacts to Production With Confidence
The Art of Deploying Artifacts to Production With ConfidenceThe Art of Deploying Artifacts to Production With Confidence
The Art of Deploying Artifacts to Production With Confidence
 
Project Flogo: Serverless Integration, Powered by Flogo and Lambda
Project Flogo: Serverless Integration, Powered by Flogo and LambdaProject Flogo: Serverless Integration, Powered by Flogo and Lambda
Project Flogo: Serverless Integration, Powered by Flogo and Lambda
 
Project Flogo: An Event-Driven Stack for the Enterprise
Project Flogo: An Event-Driven Stack for the EnterpriseProject Flogo: An Event-Driven Stack for the Enterprise
Project Flogo: An Event-Driven Stack for the Enterprise
 
The Road to a Cloud-First Enterprise
The Road to a Cloud-First EnterpriseThe Road to a Cloud-First Enterprise
The Road to a Cloud-First Enterprise
 
Building serverless apps with Go & SAM
Building serverless apps with Go & SAMBuilding serverless apps with Go & SAM
Building serverless apps with Go & SAM
 

Recently uploaded

Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Crescat
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
TheSMSPoint
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
Aftab Hussain
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
Deuglo Infosystem Pvt Ltd
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Launch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in MinutesLaunch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in Minutes
Roshan Dwivedi
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
Hironori Washizaki
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni García
 
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
mz5nrf0n
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
Rakesh Kumar R
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
Alina Yurenko
 

Recently uploaded (20)

Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Launch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in MinutesLaunch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in Minutes
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
 
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
 

Refactoring to Modules - Why, How and Everything Else I Can Fit In 45 Minutes…

  • 1. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter Refactoring to modules Why, How and Everything Else I Can Fit In 45 Minutes…
  • 2. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter A Big thanks to our hosts of today
  • 3. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter https://jfrog.com/shownotes shownotes Slides Links Comments & Ratings Raffle
  • 4. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter Who am I? • Developer Advocate • Passionate about Serverless, Containers, and all things Cloud • I love dadjokes, cheesecake and Go @LeonStigter Leon Stigter, Developer Advocate
  • 5. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter Dadjokes? What happens when you hold a Unix terminal to your ear? You can hear the C
  • 6. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter Let’s travel back in time…
  • 7. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter When did you start with Go? Let’s turn to the audience for a poll… 1.0 2012 1.2 2013 1.5 2015 1.8 2017 1.11 2018
  • 8. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter A quick history of go Go 1.0 First major milestone as a long term stable release 2012 2015 Go 1.5 First release to no longer use C (except for cgo) 2017 Go 1.8 Introduction of Go plugins 2018 Go 1.11 This is where the magic is! (at least for this talk J)
  • 9. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter Dependency Management… So what is that magic?
  • 10. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter “Tis impossible to be sure of anything but Death and Taxes” - Christopher Bullock
  • 11. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter At JFROG, we really like pipelines and promotions CI SERVER Integration System Testing If quality requirments are hit If quality requirments are hit If quality requirments are hit Staging - Quality gates - Production 1 2 3 4 *
  • 12. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter At jfrog, we absolutely love Immutable and repeatable builds The best way to guarantee issues is force push Immutable dependencies Who doesn’t remember left-pad with Node.js? Lost Dependencies Even build when GitHub is down!? Internet Issues
  • 13. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter Show me something already! ¯_(ツ)_/¯
  • 14. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter Recapping, gocenter is…
  • 15. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter Discovery Go Notifier Go Processor Go Validator Go UI Backend Go UI Node.js Built out of a few microservices
  • 16. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter Start with the why…
  • 17. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter In Go, We had a Problem… Source: Go at Google https://www.infoq.com/presentations/Go-Google
  • 18. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter One easy solution…? Dependencies are sources! Remote imports are in VCS Dump everything into a single folder Compile… Profit!!
  • 19. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter • Which dependencies I use? • Which dependencies you used? • Which dependencies I should use? • Which code I’m editing right now? • What is going on?! But… how do I know…
  • 20. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter Vendoring – the worst kind of forking “Copy all of the files at some version from one version control repository and paste them into a different version control repository”
  • 21. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter • History, branch, and tag information is lost • Pulling updates is impossible • It invites modification, divergence, and bad fork • It wastes space • Good luck finding which version of the code you forked But what is wrong with vendoring?
  • 22. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter Build your own dependency manager… “It’s not the role of the tooling provided by the language to dictate how you manage your code (...)”
  • 23.
  • 24. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter • Working in project directories • Local cache for dependencies • Version declarations • Conflict resolution Go dep – Proper dependency management?
  • 25. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter Who is using Go modules? Let’s turn to the audience for another poll… Yes No
  • 26. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter Module A module is a collection of related Go packages that are versioned together as a single unit. Let’s go over some definitions
  • 27. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter Sources A module is a tree (directory) of Go source files with a go.mod file in the root directory. Let’s go over some definitions
  • 28. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter Version Control Most often, a single version- control repository corresponds exactly to a single module Let’s go over some definitions
  • 29. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter Set the environment variable GO111MODULE to ON Use go outside of your $GOPATH Using go modules 1 2
  • 30. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter mkdir mymodule cd mymodule go mod init github.com/retgits/mymodule Creating a module
  • 31. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter • Import dependencies from Gopkg.lock go mod init <module path> • Remove unnecessary imports and add indirect imports go mod tidy • Delete the vendor folder rm –rf vendor/ • Delete Gopkg files rm Gopkg.* Moving from DEP to modules
  • 32. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter Go.mod by any other name… Would probably not work…
  • 33. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter module github.com/retgits/mymodule go 1.12 require ( github.com/naoina/go-stringutil v0.1.0 github.com/some/dependency v1.2.3 github.com/google/go-github/v25 v25.0.1 ) replace github.com/some/dependency github.com/retgits/dependency versioning
  • 34. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter module github.com/retgits/mymodule go 1.12 require ( github.com/naoina/go-stringutil v0.1.0 github.com/some/dependency v1.2.3 github.com/google/go-github/v25 v25.0.1 ) replace github.com/some/dependency github.com/retgits/dependency Replacing packages
  • 35. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter module github.com/retgits/mymodule go 1.12 require ( github.com/naoina/go-stringutil v0.1.0 github.com/some/dependency v1.2.3 github.com/google/go-github/v25 v25.0.1 ) replace github.com/some/dependency ../../Downloads/dependency Works with local folders too!
  • 36. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter • You can create the vendor folder go mod vendor • You can use the vendor folder during builds go build –mod=vendor This does mean you need to have all dependencies listed in your go.mod file But I kinda like the vendor folder?
  • 37. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter • If you run `go mod vendor`, the `vendor` directory it creates should reflect your `replace` directives. (That is: it should put the replacement content in the `vendor` directory rather than the original module content.) • But if as you say, `-mod=vendor` bypasses go.mod that makes sense. • So does `-mod=vendor` require you to have vendored all your dependencies? (edited) • Yes. If you have a complete `go.mod`, `go mod vendor` will do that for you (as Bryan said, including taking into account `replace` statements). But I kinda like the vendor folder?
  • 38. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter Houston… I think I lost my module?
  • 39. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter The <module>@v<version> construct should be immutable That means that github.com/retgits/checkiday/@v/v1.0.0 Should forever be the same… Modules are immutable
  • 40. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter But are they really? ”Friends don’t let friends do git push -f” - Aaron Schlesinger
  • 41. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter Using the goproxy variable export GOPROXY=https://myawesomeproxy.com go get github.com/retgits/checkiday
  • 42. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter Keeping modules Immediate access, not shared, can be wiped… Local cache ($GOPATH/pkg/mod) Fast access, requires infra, shared across devs Organizational cache (private proxy) Highly available, CDN, no infra, free Public cache (public proxy)
  • 43. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter And also faster builds…
  • 44. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter Before modules go get github.com/project-flogo/cli git clone https://github.com/project-flogo/cli <build module locally> With modules go get github.com/project-flogo/cli GET github.com/project-flogo/cli/@v/list GET github.com/project-flogo/cli/@v/v1.0.0.mod GET github.com/project-flogo/cli/@v/v1.0.0.zip Go get my module!
  • 45. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter • If you haven’t, start with Go modules: GO111MODULE=on • Start working outside of your $GOPATH • Use a public proxy server for immutable Go modules (like GoCenter.io) • Think about running your own proxy server (like Project Athens) Final thoughts
  • 46. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter There’s one more thing… But before I go…
  • 47. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter What is a 5* module for you? We talked about modules a bit…
  • 48. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter • https://jfrog.com/shownotes • @JFrog • #GoLang • https://gocenter.io • @LeonStigter Twitter, ads, and Q&a
  • 49. @JFrog | jfrog.com/shownotes | #GoCenter | @LeonStigter Thank you!