Solve the problem of package red reporting in import after Golan imports the project

Time:2021-8-29

terms of settlement:

1. Golan — > preferences… — > go — > gopath — > add the gopath value under the command line go env under project gopath, and modify your own project gopath

2. Under normal circumstances, we don’t need to deal with the agent of the external package by ourselves, but you may make changes inadvertently. Here, we also configure it through setting:

Supplement: after GoLand imports the project, the package in import will be red, and $gopath / go.mod exists but should not

First, if the import package cannot be found, the problem is red. Execute go env locally to find the gopath path. If you drop the project in $gopath / SRC, the project package will be found automatically.

Second question. After you enable go modules, they cannot coexist with gopath, so you can remove items from gopath. Remember to match it.

The above is my personal experience. I hope I can give you a reference, and I hope you can support developpaer. If you have any mistakes or don’t consider completely, please don’t hesitate to comment.