Golang错误:package ... :code in directory ... expects import "..."

栏目: Go · 发布时间: 6年前

内容简介:下载zap库的时候报错而且引用包的时候

下载zap库的时候

go get -u github.com/uber-go/zap

报错

package github.com/uber-go/zap: code in directory D:\GoSpace2019\src\github.com\uber-go\zap expects import "go.uber.org/zap"

而且引用包的时候

import (
    "github.com/uber-go/zap"
)

报错

'github.com/uber-go/zap' imports package that expects import "go.uber.org/zap"

查看zap的源码,发现作者开发它时的工程目录本来就是 "go.uber.org/zap",只是它的代码发布到git的目录是github.com/uber-go/zap而已

解决方案

在GOPATH/src下新建"go.uber.org/zap"文件夹,然后将代码拷贝过去。引用包也改为:

import (
    "go.uber.org/zap"
)

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Algorithms in C (Computer Science Series)

Algorithms in C (Computer Science Series)

Robert Sedgewick / Addison-Wesley Professional / 1990-01-11 / USD 59.99

This new version of the best-selling book, Algorithms, SecondEdition, provides a comprehensive collection of algorithmsimplemented in C. A variety of algorithms are described in eachofthe following ar......一起来看看 《Algorithms in C (Computer Science Series)》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

SHA 加密
SHA 加密

SHA 加密工具