Giter Club home page Giter Club logo

Comments (11)

hyper0x avatar hyper0x commented on August 27, 2024

I think should be fix 'import "../nsq"' to 'import "github.com/bitly/nsq/nsq"'.

from nsq.

jehiah avatar jehiah commented on August 27, 2024

Hi @hyper-carrot i think the error you are having is from building when this repository is checked out within your $GOPATH. If you move it outside your $GOPATH it should build fine.

from nsq.

hyper0x avatar hyper0x commented on August 27, 2024

Hi @jehiah i follow you & re-read the 'Compiling' section in readme file, but the problem is still there.

the detail:

  1. install nsq:
$ cd ~/package
(The path '~/package' is not in $GOPATH)
$ git clone https://github.com/bitly/nsq.git
$ cd nsq
$ make 
$ make install
$ go get github.com/bitly/nsq/nsq
$ pip install pynsq
  1. edit & run my go file:
$ cd ~
$ vim nsq_pubsub.go 
(cp from the official example & fix 'import "../nsq"' to 'import "github.com/bitly/nsq/nsq"')
$ go run nsq_pubsub.go

but:

nsq_pubsub.go:7:2: local import "../nsq" in non-local package

In fact, using absolute package name is the most direct & simple way. Why using that method in nsq?

Thank you.

from nsq.

mreiferson avatar mreiferson commented on August 27, 2024

@hyper-carrot can you paste the output of:

  1. go list all (which shows all of the packages you have installed)
  2. go env GOPATH
  3. pwd in the directory where you have NSQ checked out

this will help us debug the issue.

thanks!

from nsq.

hyper0x avatar hyper0x commented on August 27, 2024

OK.

$ go list all
can't load package: /home/freej/lib/golang/src/github.com/bitly/nsq/examples/bench_reader/bench_reader.go:4:2: local import "../../nsq" in non-local package
can't load package: /home/freej/lib/golang/src/github.com/bitly/nsq/examples/bench_writer/bench_writer.go:4:2: local import "../../nsq" in non-local package
can't load package: /home/freej/lib/golang/src/github.com/bitly/nsq/examples/nsq_pubsub/nsq_pubsub.go:6:2: local import "../../nsq" in non-local package
can't load package: /home/freej/lib/golang/src/github.com/bitly/nsq/examples/nsq_to_file/nsq_to_file.go:6:2: local import "../../nsq" in non-local package
can't load package: /home/freej/lib/golang/src/github.com/bitly/nsq/examples/nsq_to_http/http.go:4:2: local import "../../nsq" in non-local package
can't load package: /home/freej/lib/golang/src/github.com/bitly/nsq/nsqadmin/http.go:4:2: local import "../nsq" in non-local package
can't load package: /home/freej/lib/golang/src/github.com/bitly/nsq/nsqd/channel.go:4:2: local import "../nsq" in non-local package
can't load package: /home/freej/lib/golang/src/github.com/bitly/nsq/nsqlookupd/http.go:4:2: local import "../nsq" in non-local package
can't load package: /home/freej/lib/golang/src/github.com/bitly/nsq/util/lookupd_requests.go:4:2: local import "../nsq" in non-local package
cmd/api
cmd/cgo
cmd/fix
cmd/go
cmd/godoc
cmd/gofmt
cmd/vet
cmd/yacc
archive/tar
archive/zip
bufio
bytes
compress/bzip2
compress/flate
compress/gzip
compress/lzw
compress/zlib
container/heap
container/list
container/ring
crypto
crypto/aes
crypto/cipher
crypto/des
crypto/dsa
crypto/ecdsa
crypto/elliptic
crypto/hmac
crypto/md5
crypto/rand
crypto/rc4
crypto/rsa
crypto/sha1
crypto/sha256
crypto/sha512
crypto/subtle
crypto/tls
crypto/x509
crypto/x509/pkix
database/sql
database/sql/driver
debug/dwarf
debug/elf
debug/gosym
debug/macho
debug/pe
encoding/ascii85
encoding/asn1
encoding/base32
encoding/base64
encoding/binary
encoding/csv
encoding/gob
encoding/hex
encoding/json
encoding/pem
encoding/xml
errors
expvar
flag
fmt
go/ast
go/build
go/doc
go/parser
go/printer
go/scanner
go/token
hash
hash/adler32
hash/crc32
hash/crc64
hash/fnv
html
html/template
image
image/color
image/draw
image/gif
image/jpeg
image/png
index/suffixarray
io
io/ioutil
log
log/syslog
math
math/big
math/cmplx
math/rand
mime
mime/multipart
net
net/http
net/http/cgi
net/http/fcgi
net/http/httptest
net/http/httputil
net/http/pprof
net/mail
net/rpc
net/rpc/jsonrpc
net/smtp
net/textproto
net/url
os
os/exec
os/signal
os/user
path
path/filepath
reflect
regexp
regexp/syntax
runtime
runtime/cgo
runtime/debug
runtime/pprof
sort
strconv
strings
sync
sync/atomic
syscall
testing
testing/iotest
testing/quick
text/scanner
text/tabwriter
text/template
text/template/parse
time
unicode
unicode/utf16
unicode/utf8
unsafe
github.com/alecthomas/gozmq
github.com/alecthomas/gozmq/examples
github.com/astaxie/goredis
github.com/astaxie/goredis/redis-dump
github.com/astaxie/goredis/redis-load
github.com/astaxie/session
github.com/astaxie/session/providers/memory
github.com/bitly/go-notify
github.com/bitly/go-simplejson
github.com/bitly/nsq/nsq
github.com/bitly/nsq/util/pqueue
github.com/bitly/nsq/util/semver
github.com/bmizerany/assert
github.com/bmizerany/assert/example
github.com/kr/pretty
labix.org/v2/mgo
labix.org/v2/mgo/bson
labix.org/v2/mgo/txn
client
myutil
server
$ echo $GOPATH
/home/freej/lib/golang:/home/freej/code/golang/snippet:/home/freej/code/golang/go-web-demo

And, my nsq path: /home/freej/package/nsq

from nsq.

mreiferson avatar mreiferson commented on August 27, 2024

based on the output you pasted of go list all it looks like you might have, at some point, run go get github.com/bitly/nsq which tried to install everything in the repo rather than just the subdirectory nsq (the actual public Go package)

I would suggest you remove everything in /home/freej/lib/golang/src/github.com/bitly/nsq and /home/freej/lib/golang/pkg/<platform>_<arch>/github.com/bitly/nsq and re-install via go get github.com/bitly/nsq/nsq.

Afterwards you should not see the error output in go list all and you should be able to build/run the example apps and other NSQ binaries.

from nsq.

hyper0x avatar hyper0x commented on August 27, 2024

@mreiferson : I follow you and try it, but the problem still exist & show me same error message.

I still believe that the error occurs because incorrect package import method in nsq. I'll try it later.

Thank you very much.:-)

from nsq.

hyper0x avatar hyper0x commented on August 27, 2024

I think it can be said that github broken the original package structure (push & go get). Is that it?

from nsq.

hyper0x avatar hyper0x commented on August 27, 2024

@mreiferson @jehiah

My grasp:

  1. The code to be used for tool/library should not use local import.
  2. The code can be run independently should use local import only.

from nsq.

mreiferson avatar mreiferson commented on August 27, 2024

Yes, certainly there are other ways we could have structured this :). We don't use relative imports in any public package (ie, the subdirectory nsq). All of the binaries use relative imports to make it easier to work in git forks of this main repo without having to re-write import paths.

If you are still seeing the package errors at the top of the output of go list all then something is going wrong when you are installing the NSQ package.

What are the exact commands you are using (and output) to cleanup the existing (failed) packages and to re-install the NSQ package? I can follow along and possibly provide some insight into why this is happening.

For what it's worth, we publish pre-compiled binary distributions here.

from nsq.

hyper0x avatar hyper0x commented on August 27, 2024

@mreiferson Thank you for your reply.:)

Oops, i just solved the problem. I can be correctly run the example in nsq's example directory and my directory.

I try:

  1. I fix all of relative import to the import way base on nsq root directory, such as import "nsq". This way can be clean the package errors at the top of the output of go list all. But, in the expected, it show me a error message import "nsq": cannot find package when i go run the example in my directory.

Btw, my search & replacement method is:

$ sed -i "s/..\/nsq/nsq/g" `grep "../nsq" -rl ~/lib/golang/src/github.com/bitly/nsq/**/*.go`
$ sed -i "s/..\/util/util/g" `grep "../util" -rl ~/lib/golang/src/github.com/bitly/nsq/**/*.go`
$ sed -i "s/..\/..\/nsq/nsq/g" `grep "../../nsq" -rl ~/lib/golang/src/github.com/bitly/nsq/`
$ sed -i "s/..\/..\/util/util/g" `grep "../../util" -rl ~/lib/golang/src/github.com/bitly/nsq/`
  1. After the first step, i fix all of the import way base on nsq root directory to full path import, such as import "github.com/bitly/nsq/nsq". Then i successfullygo run the example in my directory, and it looked all right (no package error) after input go list all. (Certainly, the precondition is go get github.com/bitly/nsq/nsq)

For this, my search & replacement method is:

$ sed -i "s#\"nsq\"#\"github.com/bitly/nsq/nsq\"#g" `grep '\"nsq\"' -rl ~/lib/golang/src/github.com/bitly/nsq/**/*.go`  
$ sed -i "s#\"util\"#\"github.com/bitly/nsq/util\"#g" `grep '\"util\"' -rl ~/lib/golang/src/github.com/bitly/nsq/**/*.go`  

I hope these can help you.

from nsq.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.