问题点
缺少github.com/boombuler/barcode程序
models/util/code.go:23:2: cannot find package "github.com/boombuler/barcode" in any of: /root/gopath/src/gybadminapi/vendor/github.com/boombuler/barcode (vendor tree) /root/go/src/github.com/boombuler/barcode (from $GOROOT) /root/gopath/src/github.com/boombuler/barcode (from $GOPATH) models/util/code.go:24:2: cannot find package "github.com/boombuler/barcode/qr" in any of: /root/gopath/src/gybadminapi/vendor/github.com/boombuler/barcode/qr (vendor tree) /root/go/src/github.com/boombuler/barcode/qr (from $GOROOT) /root/gopath/src/github.com/boombuler/barcode/qr (from $GOPATH) models/util/code.go:25:2: cannot find package "github.com/golang/freetype" in any of: /root/gopath/src/gybadminapi/vendor/github.com/golang/freetype (vendor tree) /root/go/src/github.com/golang/freetype (from $GOROOT) /root/gopath/src/github.com/golang/freetype (from $GOPATH)
解决办法 :
在使用go的时候如果依赖导入github上的,比如下面样式
import "github.com/boombuler/barcode"
在/root/gopath/目录下执行下载,执行get操作
go get github.com/boombuler/barcode
它会下载到你的gopath目录下
在我们引入第三方的时候,其会在三个地方区查找
1、GOROOT路径
2、GOPATH路径
3、在原目录中的vendor目录下进行查找
get执行后,发现src目录下产生相应的目录,那么报错解决
下面安装go过程可忽略~~~~~~~~~
=============================================================
一、安装go环境
1.下载go软件包
官网:https://goproxy.io/zh/
wget https://gomirrors.org/dl/go/go1.15.2.linux-amd64.tar.gz
2.解压:
tar xf go1.15.2.linux-amd64.tar.gz
3.创建目录
go安装目录:/root/go(无需创建,解压自得)
go运行目录:mkdir -p /root/gopath
4.添加环境变量
vim /etc/profile
末尾添加:
export GOROOT=/root/go
export GOPATH=/root/gopath
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
export GOPROXY=https://goproxy.io
最后一行表示,如果在构建中缺少构建文件,将会自动下载
5.立即生效
source /etc/profile
6.查看版本
go version