Modules
18 July 2018
Reston, VA
Chris Hines
Comcast
@chris_csguy
Modules
Executive Summary
The Road Here
Structure
User Experience
Inner Workings
The Road Ahead
Executive Summary
Modules
{
The Road Here
Modules
Milestones
The Road Here
GOPATH
The Road Here
src/
github.com/golang/example/
.git/ # Git repository metadata
hello/
hello.go # command source
outyet/
main.go # command source
main_test.go # test source
stringutil/
reverse.go # package source
reverse_test.go # test source
golang.org/x/image/
.git/ # Git repository metadata
bmp/
reader.go # package source
writer.go # package source
GOPATH
The Road Here
Configuration by convention enabled
Nope
Repeatable Builds?
Experimentation
The Road Here
Codification
The Road Here
Unification
The Road Here
Redesign
The Road Here
Structure
Modules
A module is
Structure
Filesystem Structure
Structure
<any-path>/
go.mod # module file
main.go # command source
<any-path>/
.git/ # optional
go.mod # identifies the module root
hello.go # package source
hello_test.go # test source
stringutil/
reverse.go # package source
reverse_test.go # test source
go.mod
Structure
module example.com/hello
Module Path
The import path prefix of the module.
go.mod
Structure
module example.com/hello
require (
golang.org/x/text v0.3.0
gopkg.in/yaml.v2 v2.1.0
)
Dependencies
List of modules we depend on and the minimum version we can use.
go.mod
Structure
module example.com/hello
require (
golang.org/x/text v0.3.0
gopkg.in/yaml.v2 v2.1.0
)
exclude github.com/go-stack/stack v1.6.0
Exclusions
List of module versions we reject for some reason.
go.mod
Structure
module example.com/hello
require (
golang.org/x/text v0.3.0
gopkg.in/yaml.v2 v2.1.0
)
exclude github.com/go-stack/stack v1.6.0
replace (
github.com/go-stack/stack v1.4.0 => ../stack/
golang.org/x/text => github.com/pkg/errors v0.8.0
)
Replacements
List of module [versions] we replace with something else.
User Experience
Modules
Go 1.11 Module Support
User Experience
Commands
User Experience
go mod -init [-module=module-path]
go build
go test
go list -m [-u] all
go mod -sync
go help modules
go help mod
go get (module remix)
User Experience
go get github.com/gorilla/mux@latest
same (@latest is default for 'go get')
go get github.com/gorilla/mux@v1.6.2
records v1.6.2
go get github.com/gorilla/mux@e3702bed2
records v1.6.2
go get github.com/gorilla/mux@c856192
records v0.0.0-20180517173623-c85619274f5d
go get github.com/gorilla/mux@master
records current meaning of master
Live demo
User Experience
Inner Workings
Modules
Live Demo
Inner Workings
The Road Ahead
Modules
Release Plans
The Road Ahead
Ultimate Goals
The Road Ahead