猿问

Golang:安装目录错误?

我有错误:


go install: no install location for directory /Users/xwilly/Dropbox/go/project/src outside GOPATH 

我在 OS X 上使用 go 1.1 版。


我可以构建和运行,但不能安装包。


我的环境:


GOPATH=/Users/xwilly/Dropbox/go/project

PATH=/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/go/bin:/Users/xwilly/Dropbox/go/project/bin

项目树:


/Users/xwilly/Dropbox/go/project

bin

pkg

src

我可以无误地构建:


..:src xwilly$ go build test.go 

..:src xwilly$ go install test.go

go install: no install location for directory /Users/xwilly/Dropbox/go/project/src outside GOPATH

这是一个简单的例子:


xwilly$ cat test.go 

package main


import (

    "fmt"

)


func main() {

    fmt.Println("Bonjour")

}

xwilly$ go run test.go 

Bonjour

xwilly$ go install test.go 

go install: no install location for directory /Users/xwilly/Dropbox/go/project/src/learning outside GOPATH



德玛西亚99
浏览 223回答 1
1回答
随时随地看视频慕课网APP

相关分类

Go
我要回答