go build get 問題處理


 
client.go:9:2: cannot find module providing package google.golang.org/grpc: working directory is not part of a module
 
因為開啟mod模式了

export GO111MODULE=auto

 
另外一種方法就是使用mod模式

export GO111MODULE=on
go mod init
go mod vendor
#缺少什么包,go get什么包

--------------------------
[root@centos7 multissh-master]# echo $GOPATH
/root/go
[root@centos7 multissh-master]# echo $GOROOT
/usr/local/go
[root@centos7 multissh-master]# which go
/usr/local/go/bin/go
[root@centos7 multissh-master]#


--------------------------
[root@centos7 multissh-master]#  go get github.com/go-sql-driver/mysql
go: finding github.com/go-sql-driver/mysql v1.5.0
go: downloading github.com/go-sql-driver/mysql v1.5.0
go: extracting github.com/go-sql-driver/mysql v1.5.0
[root@centos7 multissh-master]#  

4. 在代碼中導入下載的那個第三方包
import (
    "github.com/go-sql-driver/mysql" // 從環境變量:%goPath% 中定義的路徑去查找第三方類庫
)

[root@centos7 multissh-master]# go get github.com/shanghai-edu/multissh
go: finding github.com/shanghai-edu/multissh latest
go: finding golang.org/x/crypto latest


[root@centos7 multissh-master]# go get github.com/shanghai-edu/multissh/funcs
go: finding github.com/shanghai-edu/multissh latest
go get github.com/shanghai-edu/multissh/funcs: no matching versions for query "upgrade"

[root@centos7 multissh-master]# go get -u -v github.com/shanghai-edu/multissh/funcs
go: finding github.com/shanghai-edu/multissh latest
go: finding golang.org/x/crypto latest
go: downloading golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad
go: extracting golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad
go: downloading golang.org/x/sys v0.0.0-20191026070338-33540a1f6037
go: extracting golang.org/x/sys v0.0.0-20191026070338-33540a1f6037
go: finding golang.org/x/sys latest
go: downloading golang.org/x/sys v0.0.0-20210123231150-1d476976d117
go: extracting golang.org/x/sys v0.0.0-20210123231150-1d476976d117
golang.org/x/crypto/internal/subtle
golang.org/x/crypto/blowfish
golang.org/x/crypto/chacha20
golang.org/x/crypto/poly1305
github.com/shanghai-edu/multissh/g
golang.org/x/crypto/curve25519
golang.org/x/crypto/ed25519
golang.org/x/crypto/ssh/internal/bcrypt_pbkdf
golang.org/x/crypto/ssh
github.com/shanghai-edu/multissh/funcs
[root@centos7 multissh-master]#

--------------------
而要讓檔案自動儲存到指令的目錄下,則需要借用-P這個參數,可以使用以下的指令
wget -P 目錄 網址
舉例來說,如果你要放到/root底下,你可以打下列的指令:
wget -P /root 網址

-----------------------------------------------------------------------
golang unrecognized import path "golang.org/x/crypto"的解決方法

用代理還是靠譜些

    [root@test rttys]# export GOPROXY=https://goproxy.io
    [root@test rttys]# export GO111MODULE=on
    [root@test rttys]# go get


------------------
go cannot find package "golang.org/x/crypto/ssh/terminal" 解決方案


    進入$GOPATH(你的安裝go 的路徑)
    進入 $GOPATH/src, 創建文件夾 golang.org, 以及子文件夾 golang.org/x
    進$GOPATH/golang.org/x 使用如下命令:
    clone crypto 以及 sys 即可

git clone https://github.com/golang/crypto.git
 
$ git clone https://github.com/golang/crypto.git
Cloning into 'crypto'...
remote: Enumerating objects: 22, done.
remote: Counting objects: 100% (22/22), done.
remote: Compressing objects: 100% (17/17), done.
remote: Total 5824 (delta 6), reused 11 (delta 5), pack-reused 5802
Receiving objects: 100% (5824/5824), 4.68 MiB | 9.00 KiB/s, done.
Resolving deltas: 100% (3720/3720), done.

-------------------------------
[root@centos7 multissh-master]# go build main.go
go: finding github.com/shanghai-edu/multissh latest
build command-line-arguments: cannot load github.com/shanghai-edu/multissh/funcs: no matching versions for query "latest"
[root@centos7 multissh-master]# pwd
/root/multissh-master
 
[root@centos7 multissh-master]# go get github.com/shanghai-edu/multissh
go: finding github.com/shanghai-edu/multissh latest
go: finding golang.org/x/crypto latest

[root@centos7 multissh-master]# go build main.go
go: finding github.com/shanghai-edu/multissh latest
go: finding golang.org/x/crypto latest
          
[root@centos7 multissh-master]#
[root@centos7 multissh-master]# go build main.go
go: finding github.com/shanghai-edu/multissh latest
build command-line-arguments: cannot load golang.org/x/crypto/ssh: cannot find module providing package golang.org/x/crypto/ssh
[root@centos7 multissh-master]#


https://www.jianshu.com/p/7d315f8551ad?utm_source=oschina-app




免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM