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 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?