When I use go mod and I have just one .go
file all things are ok and go mod
can download the external package and use it but when I use the external package in the other file (not main.go file) I get this error (when run go run main.go
)
test/test.go:4:2: cannot find package
My project structure is like this:
├── go.mod
├── go.sum
├── main.go
└── test
└── test.go
And that is my files:
main.go
package main
import (
"./test"
)
func main() {
test.Hello()
}
test.go
package test
import (
"github.com/mehrdadep/tgomod"
)
func Hello() {
tgomod.Print()
}
go.mod
module test
go 1.15
require github.com/mehrdadep/tgomod v1.0.1
go.sum
github.com/mehrdadep/tgomod v1.0.1 h1:4lxx7JE0pySHLbH52sidkkKBjJQFC8ZZej3zEX/RTWc=
github.com/mehrdadep/tgomod v1.0.1/go.mod h1:YIkzdF7Sf9nd+eC0ySxL+gGbsew7LvUh9vP3p7yzTi4=
Thanks