~/Create a Go Module Quickly

Jul 17, 2024


To make a new Go module, follow these fast steps:

First, ensure Go is installed. Then, in your project directory, run:

1
go mod init yourmodule/name

This will create a go.mod file. You can then add dependencies by using:

1
go get package/path

For example:

1
go get github.com/gorilla/mux

To build or run your code, use:

1
2
go build
go run .

See more in the official Go module guide.

Tags: [go]