Can't import packages from GOPATH

889 views
Skip to first unread message

Archos

unread,
Aug 26, 2011, 7:20:20 PM8/26/11
to golang-nuts
I've just to start using GOPATH for that packages goinstalled be in
another directory, "/var/tmp/gocode" in my case.

The packages are installed there but when I import some of them from a
program, then it shows "can't find import"

http://golang.org/cmd/goinstall

Kyle Lemons

unread,
Aug 26, 2011, 8:42:51 PM8/26/11
to Archos, golang-nuts
Can you give some more specifics?  What path you're importing and the import you're using, what GOPATH, what error(s)?

Archos

unread,
Aug 27, 2011, 4:16:26 AM8/27/11
to golang-nuts
export GOPATH=/var/tmp/gocode
mkdir $GOPATH

goinstall -clean -u github.com/kless/go-linoise/linoise

---
package main

import (
"github.com/kless/go-linoise/linoise"
)

func main() {
q := linoise.NewQuestion()
defer q.RestoreTerm()

ans, err := q.Read("What is your name?")
println(ans, err)
}
---

$ 8g hello.go
hello.go:4: can't find import: github.com/kless/go-linoise/linoise

[But in change, godoc works well when GOPATH is set]

$ godoc github.com/kless/go-linoise/linoise NewQuestion

===
Go version: last trunk

On Aug 27, 1:42 am, Kyle Lemons <kev...@google.com> wrote:
> Can you give some more specifics?  What path you're importing and the import
> you're using, what GOPATH, what error(s)?
>

songhai yu

unread,
Aug 27, 2011, 6:33:32 AM8/27/11
to golang-nuts
http://groups.google.com/group/golang-nuts/browse_thread/thread/a70c185ce5a6f026

this thread has rolved this issue, you can refer to this

Archos

unread,
Aug 28, 2011, 3:45:21 AM8/28/11
to golang-nuts
Thanks! I'll avoid the use of GOPATH, at least by now.

On Aug 27, 11:33 am, songhai yu <flex...@gmail.com> wrote:
> http://groups.google.com/group/golang-nuts/browse_thread/thread/a70c1...

John Asmuth

unread,
Aug 28, 2011, 9:12:28 AM8/28/11
to golan...@googlegroups.com
I feel like that's the wrong solution.

You can do any one of:

- add these two lines to your makefile:
  LDFLAGS += -L $GOPATH
  GCFLAGS += -I $GOPATH

- use goinstall to do your local installing (see http://golang.org/cmd/goinstall)

Reply all
Reply to author
Forward
0 new messages