Comments (11)
I think should be fix 'import "../nsq"' to 'import "github.com/bitly/nsq/nsq"'.
from nsq.
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.
Hi @jehiah i follow you & re-read the 'Compiling' section in readme file, but the problem is still there.
the detail:
- 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
- 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.
@hyper-carrot can you paste the output of:
go list all
(which shows all of the packages you have installed)go env GOPATH
pwd
in the directory where you have NSQ checked out
this will help us debug the issue.
thanks!
from nsq.
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.
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.
@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.
I think it can be said that github broken the original package structure (push & go get
). Is that it?
from nsq.
My grasp:
- The code to be used for tool/library should not use local import.
- The code can be run independently should use local import only.
from nsq.
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.
@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:
- 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 ofgo list all
. But, in the expected, it show me a error messageimport "nsq": cannot find package
when igo 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/`
- 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 inputgo list all
. (Certainly, the precondition isgo 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)
- *: Structured logging in JSON HOT 7
- Allow only a single client per channel per topic HOT 3
- topic Message to channel HOT 4
- nsqd: Support a custom CA for communicating with nsqauth HOT 4
- nsqadmin node view fails when Graphite is enabled
- Refresh Docker image HOT 5
- Docker build broken by `nsswitch.conf` check
- Can't run nsqio/nsq:v1.3.0 HOT 3
- 消费者 消费 延迟 HOT 1
- nsqd health check duplicate HOT 1
- Is there a way to peek all messages in queued? HOT 1
- chore: cleanup error handling code for Accept HOT 1
- nsqd: Use Klaus Post's compression libraries HOT 5
- nsqd: Authentication secret leaks if request fails against the nsq auth server HOT 4
- Consumption order error
- NSQ remote hosting issue HOT 1
- Having a lot of DISQUEUE errors since upgrading from 1.1.0 to 1.3.0 HOT 1
- There is an error in the statistics information
- Rebuild because of Docker base image because of security fixes for stdlib required
- nsqd:Why do we pre-allocate such a large slice space to just a topic?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nsq.