I was hit with an error when I try to run a Go script, go run somescript.go. This is a note to my future self, in case I totally forgot.
no required module provides package github.com/gofrs/uuid: go.mod file not found in current directory or any parent directory; see 'go help modules'I need to run the command below.
go mod init somescript.goThen it will output the following lines.
go: creating new go.mod: module somescript.gogo: to add module requirements and sums: go mod tidyThen run mod tidy.
go mod tidyAnd the output will be.
go: finding module for package github.com/gofrs/uuidgo: downloading github.com/gofrs/uuid v4.4.0+incompatiblego: found github.com/gofrs/uuid in github.com/gofrs/uuid v4.4.0+incompatibleThen build it.
go build somescript.goIt will create the following files
lsgo.mod go.sum somescript somescript.goRun the compiled script.
./somescript