goland中導(dǎo)包報紅和go mod問題
goland導(dǎo)包報紅
1. 原理
import的包有兩類:
(1)在go.mod中有地址的,這種需要拉到gopath/pkg下
(2)沒在go.mod的,這種在項目里,import的路徑需要從path路徑(即:/go/src/,gopath為go尋找的根路徑)為根路徑可以找到的:import github.com/CardInfoLink/quickpay/internal/ins,對應(yīng)項目所在路徑:/go/src/github.com/CardInfoLink/quickpay
2. 以前的筆記
要打開項目的直接目錄:trunk
若打開上級的話則報紅
可能有關(guān)這些配置文件的原因
go mod
go mod tidy
goland 還是報紅的話 goland Preference->Go->Go Modules(vgo) -> Enable Go Modules(vgo)intergration
jrw@wangfy:~/code/community/article$ go mod Go mod provides access to operations on modules. Note that support for modules is built into all the go commands, not just 'go mod'. For example, day-to-day adding, removing, upgrading, and downgrading of dependencies should be done using 'go get'. See 'go help modules' for an overview of module functionality. Usage: go mod <command> [arguments] The commands are: download download modules to local cache edit edit go.mod from tools or scripts graph print module requirement graph init initialize new module in current directory tidy add missing and remove unused modules vendor make vendored copy of dependencies verify verify dependencies have expected content why explain why packages or modules are needed Use "go help mod <command>" for more information about a command.
GO111MODULE=on
export GOPROXY=https://goproxy.io
sudo chmod -R 777 /工作目錄 (-R:是指幾連醫(yī)用到目錄里所有子目錄和文件;777:是指所有用戶都擁有的最高權(quán)限)
go mod tidy
總結(jié)
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
教你利用Golang可選參數(shù)實現(xiàn)可選模式
本文討論Golang函數(shù)可選參數(shù)及函數(shù)類型,以及如何利用可選函數(shù)類型實現(xiàn)可選模式。同時通過構(gòu)造函數(shù)作為示例,實現(xiàn)強大帶可選參數(shù)的構(gòu)造函數(shù),讓代碼更直觀、靈活、支持?jǐn)U展2023-01-01CentOS7使用yum安裝Golang的超詳細(xì)步驟
CentOS默認(rèn)并沒有安裝golang運行環(huán)境,下面這篇文章主要給大家介紹了關(guān)于CentOS7使用yum安裝Golang的超詳細(xì)步驟,文中通過實例代碼介紹的非常詳細(xì),需要的朋友可以參考下2023-02-02Go Excelize API源碼閱讀GetPageLayout及SetPageMargins
這篇文章主要為大家介紹了Go Excelize API源碼閱讀GetPageLayout及SetPageMargins的方法示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2022-08-08go?goroutine實現(xiàn)素數(shù)統(tǒng)計的示例
這篇文章主要介紹了go?goroutine實現(xiàn)素數(shù)統(tǒng)計,本文通過示例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2022-07-07go語言執(zhí)行等待直到后臺goroutine執(zhí)行完成實例分析
這篇文章主要介紹了go語言執(zhí)行等待直到后臺goroutine執(zhí)行完成的方法,實例分析了Go語言中WaitGroup的使用技巧,需要的朋友可以參考下2015-03-03