Skip to content

Instantly share code, notes, and snippets.

@DoZator
Created May 20, 2021 09:34
Show Gist options
  • Save DoZator/d8c275ccf399b83d599ddcf3a6532838 to your computer and use it in GitHub Desktop.
Save DoZator/d8c275ccf399b83d599ddcf3a6532838 to your computer and use it in GitHub Desktop.
Golang modules

Creating a Go module

Inside our project directory, we're going to initialize our project as a Go module.

$ go mod init github.com/DoZator/my-new-project

Directly adding dependency to the go.mod file

require github.com/someuser/package v1.0.0

go.mod file will look like below

module github.com/DoZator/my-new-project

go 1.16.3

require github.com/someuser/package v1.0.0

Download newly added dependency

$ go mod download

All dependencies in our package are shown as follows

$ go list -m all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment