dou1908 2018-04-13 01:34
浏览 95
已采纳

无法再在Golang中加载软件包

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)

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"

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

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

EDIT:

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
")
    }
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

SOLUTION:

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.

  • 写回答

1条回答 默认 最新

  • dougutuo9879 2018-04-16 16:20
    关注

    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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求京东批量付款能替代天诚
  • ¥15 slaris 系统断电后,重新开机后一直自动重启
  • ¥15 51寻迹小车定点寻迹
  • ¥15 谁能帮我看看这拒稿理由啥意思啊阿啊
  • ¥15 关于vue2中methods使用call修改this指向的问题
  • ¥15 idea自动补全键位冲突
  • ¥15 请教一下写代码,代码好难
  • ¥15 iis10中如何阻止别人网站重定向到我的网站
  • ¥15 滑块验证码移动速度不一致问题
  • ¥15 Utunbu中vscode下cern root工作台中写的程序root的头文件无法包含