无法再在golang中加载软件包 [英] Can't load packages any more in golang

查看:94
本文介绍了无法再在golang中加载软件包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎无法弄清楚。我当时用我的Windows PC进行开发并部署到Linux机器上就很好了,突然之间,我无法再编译任何东西了,甚至连一个简单的hello world程序都没有。可能是Windows更新之后。我所做的一切都会带回来这种错误:

I can't seem to figure this out. I was using my windows pc to develop and deploy on to a linux machine just fine, when all of a sudden I can't get go to compile anything any more, not even a simple hello world program. It may have been after a windows update. Everything I do comes back with this sort of error:

F:\OneDrive\Projects\gows\src\zonemaster>go install
can't load package: package zonemaster: cannot find package "zonemaster" in 
any of:
    C:\Go\src\zonemaster (from $GOROOT)
    F:\OneDrive\Projects\gows\src\zonemaster (from $GOPATH)

GOROOT和GOPATH像往常一样正确设置,但是找不到任何包。这在我拥有的每个单个包装上均失败。上面的程序是软件包 main的一部分。

The GOROOT and GOPATH are set correctly, as they always have been, but it can't find any packages. This fails on every single package I have. The above program is part of package "main"

我已经更新了Go到1.10.1并设置并重新检查了所有路径,但是没有任何效果。

I've updated Go to 1.10.1 and set and rechecked all the paths, but nothing works.

当我尝试构建它时,它说:

When I try to build it, it says this:

F:\OneDrive\Projects\gows\src\zonemaster>go build zonemaster.go
can't load package: package main: cannot find package "." in:
        F:\OneDrive\Projects\gows\src\zonemaster

zonemaster.go 的第一行是程序包的主程序(与我所有的非编译程序一样)。

The first line of zonemaster.go is package main (as with all of my non-compiling programs).

这里是我的环保产品,以帮助:

Here's my go env in case that helps:

set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\ameet\AppData\Local\go-build
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=F:\OneDrive\Projects\gows
set GORACE=
set GOROOT=C:\Go
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\ameet\AppData\Local\Temp\go- 
   build874557962=/tmp/go-build -gno-record-gcc-switches

编辑:

即使我运行了一个简单的hello.go,我也遇到了同样的问题:

Even if I run a simple hello.go I have the same problem:

F:\OneDrive\Projects\gows\src\hello>cat hello.go
    package main

    import "fmt"

    func main() {
        fmt.Printf("hello, world\n")
    }
F:\OneDrive\Projects\gows\src\hello>go build hello.go
can't load package: package main: cannot find package "." in:
        F:\OneDrive\Projects\gows\src\hello

解决方案:

原来是一个驱动器更新是问题所在。我按照Phrozens的建议将go工作区文件夹复制到其他位置,在OneDrive设置中取消选中按需文件,删除了OneDrive文件夹中的gows文件夹,然后将其从备份中复制回去。文件现在可以再次在我的OneDrive文件夹中正常编译。

It turns out a onedrive update was the problem. I copied my go workspace folder somewhere else as per Phrozens' suggestion, unticked "Files on Demand" in OneDrive settings, deleted the gows folder in my OneDrive folder, and copied it back in from the backup. Files now compile as normal inside my OneDrive folder again.

推荐答案

我只是遇到了同样的问题,而且显然与最新的OneDrive更新。我只是在其他地方创建了一个测试目录,设置了我的GOPATH并像超级按钮一样工作,我不知道为什么,但是直到现在我一直在OneDrive上工作而没有问题。

I just had the same problem and apparently it has to do with the most recent OneDrive update. I just created a test directory elsewhere, setup my GOPATH and worked like a charm, I don't know why, but I have always worked from OneDrive without issues until now.

https://github.com/golang/go/issues/22579

这篇关于无法再在golang中加载软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆