doupao6698 2015-01-06 23:40
浏览 427
已采纳

继续安装:“无法加载软件包”(即使设置了GOPATH)

I'm just getting started with the Go programming language and installed Go using the Windows installer from the website. I tested installation by using go run hello.go and that works. The problem comes when I try to build my first program:

$ echo $GOROOT
C:\Go\
$ echo $GOPATH
/cygdrive/c/Users/Paul/Documents/Home/go
mkdir -p $GOPATH/src/hello

Inside that directory I have a simple hello.go program:

package main

import "fmt"

func main() {
    fmt.Printf("Hello, world.
")
}

The problem comes when I try to build and install:

$ go install hello
can't load package: package hello: cannot find package "hello" in any of:
    C:\Go\src\hello (from $GOROOT)
    \cygdrive\c\Users\Paul\Documents\Home\go\src\hello (from $GOPATH)
  • 写回答

1条回答 默认 最新

  • dongxiang7276 2015-01-07 02:37
    关注

    GOPATH environment variable must contain valid path.

    \cygdrive\c\Users\Paul\Documents\Home\go\src\hello is not a valid path on Windows.

    Try setting GOPATH=c:\Users\Paul\Documents\Home\go instead.

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

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?