go build报错cannot find package
go env 关键数据是这样的
GOPATH="/home/zzy/goProject"
GOROOT="/usr/local/go"
项目目录是这样的
goProject
├── bin
├── pkg
└── src
└── go_learn
└── day01
├── hello
│ ├── hello
│ └── hello.go
└── str_type
├── str.go
└── world.go
hello.go我的代码是这样的
package main import (
"fmt"
"go_learn/day01/str_type/world" ## 这句导入包,一直报错
)
func main() {
fmt.Print("hello world")
test()
}
world.go代码是这样的
package main
import "fmt"
func test() {
fmt.Print("啦啦啦啦")
}
go build 报错是这样的
$ go build
hello.go:5:2: cannot find package "go_learn/day01/str_type/world" in any of:
/usr/local/go/src/go_learn/day01/str_type/world (from $GOROOT)
/home/zzy/goProject/src/go_learn/day01/str_type/world (from $GOPATH)
最后解决了!十分low的一个问题,估计初学者才会犯
world.go文件内容改一下就可以
package world # 是个文件,不是包,不要导入main import "fmt" # 函数名大写,就可以在外面引用该函数
func Test() {
fmt.Println("lll") }
go build报错cannot find package的更多相关文章
- 报错:No package erlang available
问题 yum install erlang 报错:No package erlang available 同样的,如果我们在安装nginx的时候出现"No package nginx ava ...
- 使用iview-project 打包build报错,ERROR in xxxxx.cheunk.js from UglifyJs
一.iview-project 为iview官方推荐工程,一个基于iview的vue脚手架 github网址:https://github.com/iview/iview-project 废话不多说 ...
- nginx报错:No package erlang available
问题 yum install erlang 报错:No package erlang available 同样的,如果我们在安装nginx的时候出现"No package nginx ava ...
- 执行gulp build报错
问题与分析 在执行gulp build报错如下: D:\coding\Resume\Resumes>gulp build gulp build[5628]: src\node_contextif ...
- linux 报错:E: Package 'libmemcached' has no installation candidate
linux 报错:E: Package 'libmemcached' has no installation candidate 网上查资料说是软件安装源没有这个软件,需要添加软件源. 1.备份源列表 ...
- vue-electron 使用sqlite3数据库,执行npm run build 报错 .NET Framework 2.0 SDK,Microsoft Visual Studio 2005[C:\temp\wechat\node_modules\sqlite3\build\binding.sln]
问题描述 vue-electron 使用sqlite3数据库,执行npm run build 报错如下: .NET Framework 2.0 SDK,Microsoft Visual Studio ...
- CentOS 8安装Docker报错(Problem: package docker-ce-3:19.03.8-3.el7.x86_64 requires containerd.io >= 1.2.)
CentOS8安装docker和docer-conpose 报错如下Problem: package docker-ce-3:19.03.8-3.el7.x86_64 requires contain ...
- 【gradle报错】error: package org.apache.http does not exist
导入项目的时候gradle报错 error: package org.apache.http does not exist 解决方法: 在build.gradle中加入 android { use ...
- 关于VSTS自动Build报错问题之Microsoft.Net.Compilers
报错内容如下: --06T11::.6035712Z ##[error]Dotnet command failed with non-zero exit code on the following p ...
随机推荐
- 54.Counting Bits( 计算1的个数)
Level: Medium 题目描述: Given a non negative integer number num. For every numbers i in the range 0 ≤ ...
- Windows开发,关于通过写代码加载PDB的那些事
最近,接到一个活,要写一个程序,用来批量分析一堆dll和对应的PDB, 其实工作很简单,就是根据一堆偏移,通过PDB文件,找到对应dll里面对应位置的明文符号, 简单的需求,实现起来,通常都很麻烦, ...
- 点击td对同行的其他td进行操作
假设有这样的一段tr: <tr> <td><input type="checkbox" name="item" class=&qu ...
- 【记录】ELK之logstash同步mysql数据到Elasticsearch ,配置文件详解
本文出处:https://my.oschina.net/xiaowangqiongyou/blog/1812708#comments 截取部分内容以便学习 input { jdbc { # mysql ...
- redis笔记3-命令
通用命令:keys * --查询所有keykeys list* --查询list开头的keytype key1 --查询键对应的value类型del key --删除指定的keyttl key --查 ...
- C 给定路径遍历目录下的所有文件
在此之前需要了解 WIN32_FIND_DATA的结构 以及 FindFirstFile. FindNextFile原型以及用法注意事项传送门如下 https://msdn.microsoft.co ...
- go(一)基础知识
一.第一个程序 基本程序结构 package main // 包 import "fmt" // 引入依赖代码 // 功能实现 func main() { fmt.Println( ...
- react app相关知识
1.快速新建名为hello-world项目的应用命令 npx create-react-app hello-world 2.使用serve来mock数据 ①先安装serve npm i ...
- 阿里云公共DNS正式发布支持IPv6的版本
在10月23日召开的GNTC 2019全球网络技术大会IPv6分论坛上,阿里云高级技术专家张先国宣布支持阿里公共DNS的IPv6版本正式发布,即阿里公共DNS在保持IPv4 稳定解析服务的基础上(An ...
- BlueStore-先进的用户态文件系统《二》-BlueFS
https://zhuanlan.zhihu.com/p/46362124 简介 上一篇文章中,介绍了BlueStore的诞生背景.逻辑架构以及设计思想,提到了在BlueStore中元数据都是存放在R ...