zoukankan      html  css  js  c++  java
  • 解决go打包时报错 models/util/code.go:23:2: cannot find package "github.com/boombuler/barcode" in any of:

    问题点
    缺少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

  • 相关阅读:
    解决Visual Code安装中文插件失败问题
    【转】python的复制,深拷贝和浅拷贝的区别
    Python中正则匹配使用findall时的注意事项
    【转载】正则表达式全部符号解释
    旧文章搬运完毕
    【旧文章搬运】VC插件中如何获取当前工程的工作目录
    【旧文章搬运】在64位系统上调试32位程序
    NLP常见任务介绍
    window10下pytorch和torchvision CPU版本安装
    tensorflow2.0安装
  • 原文地址:https://www.cnblogs.com/yangzp/p/13741073.html
Copyright © 2011-2022 走看看