GO-vatar series: Introduction to the Go Module

https://miro.medium.com/max/1200/1*LutJiAc3Wdg-5GtOpP9YXw.png

Help

First, let’s assume we don’t know anything about module. Let’s type go mod --help .

Init

I created new project outside $GOPATH. When I try to generate new module, I’ve got this.

Download

Some of our code might need another package outside internal package from Golang. In this way, we can provide dependency on the packages we need.

Tidy

We’ve download too many packages until we’re not realize that actually we don’t need some of the packages. Be calm. We only need to run go mod tidy. This will keep the module up to date with the source code needed. We just downloaded the Godog package, but we’re not called it yet. Do we need that package? I think no. Let’s tidy it.

Vendor

So we removed the Godog package. Let’s change the code.

go mod vendor result. The pckage is copied to workspace folder

Edit

https://golang.org/ref/mod#go-mod-edit
github.com/DATA-DOG/godog
github.com/cucumber/godog/cmd/godog

Graph

“print module requirement graph”. For example, we require 1 or 2 package in go.mod file.

Verify

We could do this after go mod download. This to make sure go.sum file has matches with module we’ve downloaded. What is go.sum file?

Why

Why we need the packages or the modules? We can sneak a peek the info with this command.

https://i.ytimg.com/vi/rBZOOtEsbxg/maxresdefault.jpg

mpermperpisang official Medium account..MperMperPisang World on Youtube

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store