Recipe for Go Modules

A presentation at Go Atlanta Meetup in February 2020 in Atlanta, GA, USA by Kat Cosgrove

Slide 1

Slide 1

A Recipe for Migrating to Go Modules

Slide 2

Slide 2

Modules are the Default …and migrating is easier than you think!

Slide 3

Slide 3

Mender.io ◂ Used for large-scale IoT deployments ◂ Build as a collection of microservices ◂ Varying version tags between services @Dixie3Flatline jfrog.com/shownotes @jfrog 3

Slide 4

Slide 4

Get a go.mod file go mod init ◂ ◂ ◂ ◂ ◂ Glide Godeps Govendor Dep … and more! v2+ ◂ ◂ ◂ ◂ Slightly more complex Increment major version Add to module path Causes some other issues to address `go mod init github.com/mendersoftware/deviceauth/v3’ @Dixie3Flatline jfrog.com/shownotes @jfrog 4

Slide 5

Slide 5

Update imports ◂ ◂ ◂ ◂ @Dixie3Flatline Build and test Both will likely fail Update import statements for new path May want to use a script for this in large projects jfrog.com/shownotes @jfrog 5

Slide 6

Slide 6

Module Versioning ◂ After go mod init or go mod tidy, check version numbers ◂ Some dependencies may cause problems here ◂ Untagged changes in satori/go.uuid broke Mender ◂ At this point, you should be able to build and run tests @Dixie3Flatline jfrog.com/shownotes @jfrog 6

Slide 7

Slide 7

Module Proxy ◂ ◂ ◂ ◂ JFrog GoCenter Immutable and persistent modules Much faster than cloning Consistent, secure, reproducible builds export GOPROXY=https://gocenter.io @Dixie3Flatline jfrog.com/shownotes @jfrog 7

Slide 8

Slide 8

Static Analysis and Code Generators ◂ Some projects may need to handle additional issues with paths here ◂ Remember to look at your .proto and Dockerfiles @Dixie3Flatline jfrog.com/shownotes @jfrog 8

Slide 9

Slide 9

Testing Changes ◂ Go v1.13 made changes to testing ◂ Specifically, when flags are parsed ◂ Move flag.Parse() to main test function @Dixie3Flatline jfrog.com/shownotes @jfrog 9

Slide 10

Slide 10

Thanks! Any questions? You can find me at ◂ ◂ ◂ @Dixie3Flatline katc@jfrog.com jfrog.com/shownotes 10