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的更多相关文章

  1. 报错:No package erlang available

    问题 yum install erlang 报错:No package erlang available 同样的,如果我们在安装nginx的时候出现"No package nginx ava ...

  2. 使用iview-project 打包build报错,ERROR in xxxxx.cheunk.js from UglifyJs

    一.iview-project  为iview官方推荐工程,一个基于iview的vue脚手架 github网址:https://github.com/iview/iview-project 废话不多说 ...

  3. nginx报错:No package erlang available

    问题 yum install erlang 报错:No package erlang available 同样的,如果我们在安装nginx的时候出现"No package nginx ava ...

  4. 执行gulp build报错

    问题与分析 在执行gulp build报错如下: D:\coding\Resume\Resumes>gulp build gulp build[5628]: src\node_contextif ...

  5. linux 报错:E: Package 'libmemcached' has no installation candidate

    linux 报错:E: Package 'libmemcached' has no installation candidate 网上查资料说是软件安装源没有这个软件,需要添加软件源. 1.备份源列表 ...

  6. 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 ...

  7. 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 ...

  8. 【gradle报错】error: package org.apache.http does not exist

    导入项目的时候gradle报错 error: package org.apache.http does not exist 解决方法: 在build.gradle中加入 android {   use ...

  9. 关于VSTS自动Build报错问题之Microsoft.Net.Compilers

    报错内容如下: --06T11::.6035712Z ##[error]Dotnet command failed with non-zero exit code on the following p ...

随机推荐

  1. 【记录】vue构建项目npm install错误run `npm audit fix` to fix them, or `npm audit` for details

    今天构建vue项目执行npm install初始化后报错 run `npm audit fix` to fix them, or `npm audit` for details 出现这问题控制台会有一 ...

  2. JAVA中的SimpleDateFormat yyyy和YYYY的区别

    最近有一个功能是对输入的日期格式化,设计给出的范例是 YYYY-MM-dd HH:mm:ss,于是我简单验证了一下是可以的,然后就这么在手册里写了.然后偶然发现有地方也用yyyy啊,这个到底有神马区别 ...

  3. oracle trim无效?

    这里说说如果是全角空格怎么去除 方法一 trim(TO_SINGLE_BYTE('aaa')) 方法二 SELECT TRIM(replace('aaa',' ','')) FROM dual

  4. python3.x current_question

    扩散四维过程遇到的问题,暂不能解决,但先收集起来. ''' list_str=['test', None, '', 'str', ' ', 'END'] data = filter(lambda st ...

  5. numpy.unique

    Find the unique elements of an array. Returns the sorted unique elements of an array. There are thre ...

  6. 【和孩子一起学编程】 python笔记--第二天

    第六章 GUI:用户图形界面(graphical user interface) 安装easygui:打开cmd命令窗口,输入:pip install easygui 利用msgbox()函数创建一个 ...

  7. Git分支,合并,切换分支的使用

    1.创建合并分支 在我们每次的提交,Git都把它们串成一条时间线,这条时间线就是一个分支.截止到目前,只有一条时间线,在Git里,这个分支叫主分支,即master分支.HEAD指针严格来说不是指向提交 ...

  8. SSD接口详解,再也不会买错固态硬盘了

    http://stor.51cto.com/art/201808/582349.htm 硬盘知识科普中,我们提到了SSD的发展史虽短,但是种类和协议比HDD不知道多到哪里去了.因此,本期小编就通过接口 ...

  9. 在idea下开发出现404错误

    用idea开发时,我们一般要设置project strucure里的Modules-Sources,里面对应的有Sources,tests,Resources,Test Resources, Excl ...

  10. Vue - 前端本地项目开发过程中webpack打包内存泄漏问题解决方法

    编译项目出现如下错误: FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory 原因: n ...