Malformed Module Path "my-api-server/my-utils/uuid" When Migrating from GOPATH-Based Dep to Go Mod
When migrating from GOPATH-based dep to Go mod, you may encounter the following error:
$ go version 1.13.3 $ go run main.go build command-line-arguments: cannot load my-api-server/my-utils/uuid: malformed module path "my-api-server/my-utils/uuid": missing dot in first path element
Cause:
The error occurs because the first part of the module path, "my-api-server," is not a valid domain or path with a period (".").
Solution:
To resolve this issue, you need to create a "go.mod" file at the root of your project (e.g., "my-api-server/go.mod"). The go.mod file should contain the following information:
Once you have created the go.mod file, you can import the "uuid" package using the full module path, like so:
import "github.com/your-github-username/my-api-server/my-utils/uuid"
Additional Tips:
https://blog.golang.org/using-go-modules
The above is the detailed content of Why Does My Go Project Show a 'Malformed Module Path' Error After Switching from GOPATH to Go Modules?. For more information, please follow other related articles on the PHP Chinese website!