天天看點

goland 解決 cannot resolve directory 'xxxx'問題

發現問題

今天好好的項目突然就好多依賴标紅了,go.mod 也全是紅的,但是執行 ​

​go mod tidy​

​​ 和 ​

​sh build.sh​

​​ 都沒有問題,但是看到标紅就渾身難受,自己搗鼓了一通,發現沒啥用,最後發現了 ​

​cannot resolve directory 'gocarina'​

​ 這個報錯,抱着死馬當活馬醫的心态上某度搜了一下,發現了不少解決方案。

goland 解決 cannot resolve directory 'xxxx'問題
goland 解決 cannot resolve directory 'xxxx'問題

圖源:解決cannot resolve directory問題

原因

原因是Goland 編輯器中項目設定為 go modules 項目,導緻從gomod讀取,進而飄紅

解決方案

點選 Goland -> Perferences -> Go -> Go modules,勾選上 ​

​Enable Go modules integration​

​,依次點選 「Apply」和 「OK」,馬上就恢複正常了。

goland 解決 cannot resolve directory 'xxxx'問題

繼續閱讀