my directory set up is like below
.
├── go.mod
├── main.go
└── urlshort
└── urlshort.go
go.mod
module fromscratch_urlshort
go 1.22.3
root dir name is fromscratch_urlshort
, I did
go mod init fromscratch_urlshort
top of urlshort.go
is
package urlshort
in main.go
I do
import(
"urlshort"
)
when I run code I got error saying
go run main.go main.go:6:2: package urlshort is not in std (/usr/local/go/src/urlshort)
What am I doing wrong here ? My objective is to import the local module urlshort
in main.go
P.S. what is a good way to set up go module when pulling a go project from a repo say github ? would the pulled directory work with go mod init
? what needs to be done ?