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. mac 支持rz sz

    安装 lrzsz brew install lrzsz 配置 iTerm2 安装完成后我们需要在 iTerm2 中使用的话,还需要一些配置 进入到 /usr/local/bin 目录下,下载两个脚本文 ...

  2. 讲真,下次打死我也不敢随便改serialVersionUID了

    讲真,下次打死我也不敢随便改serialVersionUID了 码农沉思录 码农沉思录 微信号 code-thinker 功能介绍 笔者为国内某知名企业不知名码农,专注Java Web领域多年,有丰富 ...

  3. 51.Lowest Common Ancestor of a Binary Tree(二叉树的最小公共祖先)

    Level:   Medium 题目描述: Given a binary tree, find the lowest common ancestor (LCA) of two given nodes ...

  4. wireshark 识别http的标准

    使用route add 本机ip 255.255.255.255 网关ip metric 1 的方式 会使访问本机ip的连接发送到局域网内,这样wireshark就可以抓取到 但有一点需要注意 如果本 ...

  5. 自定义 MessageBox 组件

    效果: 公共组件页面: js部分: <script>   export default {     props: {       title: {         type: String ...

  6. JavaScript 中的 this 并不难

    js学习笔记 --- this 详解 js中的this,如果没有深入的学习了解,那么this将会是让开发人员很头疼的问题.下面,我就针对this,来做一个学习笔记. 1.调用位置 在理解this的绑定 ...

  7. 第十章 Ingress

    一.资料信息 Ingress-Nginx github 地址:https://github.com/kubernetes/ingress-nginx Ingress-Nginx 官方网站:https: ...

  8. Linux xargs 命令

    xargs xargs 是给命令传递参数的一个过滤器,也是组合多个命令的一个工具. xargs 可以将管道或标准输入(stdin)数据转换成命令行参数,也能够从文件的输出中读取数据. xargs 也可 ...

  9. React 组件嵌套 父子关系

    代码实例; <!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset=" ...

  10. python 字符串中替换字符

    今天本来打算写个程序,替换字符串中固定的一个字符:将<全部替换成回车'\n' 于是,我写成这样 s='sdjj<ddd<denj,>' for x in s: if x=='& ...