Cannot load xxx: cannot find module providing package xxx

Environmental Description;
IDE:VSCode Version:1.36.1

GO Version : go1.12.3 darwin/amd64

GOPATH: /Users/xxx/go:/Users/xxx/Desktop/xxx
Directory of this Demo:/Users/xxx/Desktop/redis go; GO111MODULE is not set in GOPATH
Go mudule is used in Demo, so go InferGopath is set to false
Code organization
—src
—hosts
— host.go
—main
— main.go
—redisclient
— redisC
— go.mod
— go.sum
Src directory, go.mod, go Sum is at the same level
Hosts is a custom package
RedisClient package is some settings for Redis
Error content
build Stephanie. io/main:cannot load hosts: cannot find module providing package hosts
It’s not easy to sort it out. If this question is useful to you, please click the up arrow on the top left. Thank you!; The problem was stepped on… o (╥ ﹏ ╥) o
Expect answers
Give ideas and reference content
Own experience
Code of each document
host.go
package hosts
import (
“fmt”
)
// SayHello …
func SayHello(){
fmt.Println(“Hello!”)
}
main.go
package main
import (
“hosts”
)
func main() {
hosts.SayHello()
}
redisC.go
This package is introduced in order to practice the use of go mudule to introduce and use the third-party package Redis. Don't pay too much attention to the content here
package rediscilent
import (
github.com/gomodule/redigo/redis
“log”
)
// OpenRedisDial …
func OpenRedisDial()(conn redis.Conn, err error) {
//address can connect
c,err := redis. Dial(“tcp”, “192.168.0.248:6379”)
if err != nil {
log.Fatalln(err)
}
return c,err;
}
go.mod
module stephanie.io
go 1.12
require github. com/gomodule/redigo v2.0.0+incompatibl
Note: The module is named Stephanie The content of go. sum doesn’t make much sense here, so it won’t be posted

Sum is at the same level
Hosts is a custom package.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.