diff --git a/.travis.yml b/.travis.yml index 5045d4f67..7163076df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ sudo: false go: - 1.12.x - 1.11.x -go_import_path: github.com/nats-io/go-nats +go_import_path: github.com/nats-io/nats.go install: - go get -t ./... - go get github.com/nats-io/nats-server diff --git a/README.md b/README.md index 4097c35ba..01a550b97 100644 --- a/README.md +++ b/README.md @@ -3,13 +3,13 @@ A [Go](http://golang.org) client for the [NATS messaging system](https://nats.io [![License Apache 2](https://img.shields.io/badge/License-Apache2-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0) [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fnats-io%2Fgo-nats.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fnats-io%2Fgo-nats?ref=badge_shield) -[![Go Report Card](https://goreportcard.com/badge/github.com/nats-io/go-nats)](https://goreportcard.com/report/github.com/nats-io/go-nats) [![Build Status](https://travis-ci.org/nats-io/go-nats.svg?branch=master)](http://travis-ci.org/nats-io/go-nats) [![GoDoc](https://godoc.org/github.com/nats-io/go-nats?status.svg)](http://godoc.org/github.com/nats-io/go-nats) [![Coverage Status](https://coveralls.io/repos/nats-io/go-nats/badge.svg?branch=master)](https://coveralls.io/r/nats-io/go-nats?branch=master) +[![Go Report Card](https://goreportcard.com/badge/github.com/nats-io/nats.go)](https://goreportcard.com/report/github.com/nats-io/nats.go) [![Build Status](https://travis-ci.org/nats-io/nats.go.svg?branch=master)](http://travis-ci.org/nats-io/nats.go) [![GoDoc](https://godoc.org/github.com/nats-io/nats.go?status.svg)](http://godoc.org/github.com/nats-io/nats.go) [![Coverage Status](https://coveralls.io/repos/nats-io/nats.go/badge.svg?branch=master)](https://coveralls.io/r/nats-io/nats.go?branch=master) ## Installation ```bash # Go client -go get github.com/nats-io/go-nats +go get github.com/nats-io/nats.go # Server go get github.com/nats-io/nats-server @@ -18,7 +18,7 @@ go get github.com/nats-io/nats-server ## Basic Usage ```go -import nats "github.com/nats-io/go-nats" +import nats "github.com/nats-io/nats.go" // Connect to a server nc, _ := nats.Connect(nats.DefaultURL) diff --git a/bench/bench.go b/bench/bench.go index 2dc496bf1..58fc457c1 100644 --- a/bench/bench.go +++ b/bench/bench.go @@ -1,4 +1,4 @@ -// Copyright 2016-2018 The NATS Authors +// Copyright 2016-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -22,7 +22,7 @@ import ( "strconv" "time" - "github.com/nats-io/go-nats" + "github.com/nats-io/nats.go" "github.com/nats-io/nuid" ) diff --git a/bench/benchlib_test.go b/bench/benchlib_test.go index 2fa43a504..d3b515c0f 100644 --- a/bench/benchlib_test.go +++ b/bench/benchlib_test.go @@ -1,4 +1,4 @@ -// Copyright 2016-2018 The NATS Authors +// Copyright 2016-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -19,7 +19,7 @@ import ( "testing" "time" - "github.com/nats-io/go-nats" + "github.com/nats-io/nats.go" ) const ( diff --git a/enc.go b/enc.go index 43cfc79e9..6d5c27905 100644 --- a/enc.go +++ b/enc.go @@ -1,4 +1,4 @@ -// Copyright 2012-2018 The NATS Authors +// Copyright 2012-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -21,7 +21,7 @@ import ( "time" // Default Encoders - "github.com/nats-io/go-nats/encoders/builtin" + "github.com/nats-io/nats.go/encoders/builtin" ) // Encoder interface is for all register encoders diff --git a/enc_test.go b/enc_test.go index ca170e8bc..94c3e1aed 100644 --- a/enc_test.go +++ b/enc_test.go @@ -1,4 +1,4 @@ -// Copyright 2012-2018 The NATS Authors +// Copyright 2012-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -18,9 +18,9 @@ import ( "testing" "time" - . "github.com/nats-io/go-nats" - "github.com/nats-io/go-nats/encoders/protobuf" - "github.com/nats-io/go-nats/encoders/protobuf/testdata" + . "github.com/nats-io/nats.go" + "github.com/nats-io/nats.go/encoders/protobuf" + "github.com/nats-io/nats.go/encoders/protobuf/testdata" ) // Since we import above nats packages, we need to have a different @@ -28,7 +28,7 @@ import ( const ENC_TEST_PORT = 8268 var options = Options{ - Url: fmt.Sprintf("nats://localhost:%d", ENC_TEST_PORT), + Url: fmt.Sprintf("nats://127.0.0.1:%d", ENC_TEST_PORT), AllowReconnect: true, MaxReconnect: 10, ReconnectWait: 100 * time.Millisecond, diff --git a/encoders/protobuf/protobuf_enc.go b/encoders/protobuf/protobuf_enc.go index 1a731056f..7cf677919 100644 --- a/encoders/protobuf/protobuf_enc.go +++ b/encoders/protobuf/protobuf_enc.go @@ -17,7 +17,7 @@ import ( "errors" "github.com/golang/protobuf/proto" - "github.com/nats-io/go-nats" + "github.com/nats-io/nats.go" ) // Additional index for registered Encoders. diff --git a/example_test.go b/example_test.go index f01017632..f23f69073 100644 --- a/example_test.go +++ b/example_test.go @@ -1,4 +1,4 @@ -// Copyright 2012-2018 The NATS Authors +// Copyright 2012-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -17,7 +17,7 @@ import ( "fmt" "time" - "github.com/nats-io/go-nats" + "github.com/nats-io/nats.go" ) // Shows different ways to create a Conn diff --git a/examples/nats-bench/main.go b/examples/nats-bench/main.go index 9f0d02ca6..bbcfaa103 100644 --- a/examples/nats-bench/main.go +++ b/examples/nats-bench/main.go @@ -1,4 +1,4 @@ -// Copyright 2015-2018 The NATS Authors +// Copyright 2015-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -22,8 +22,8 @@ import ( "sync" "time" - "github.com/nats-io/go-nats" - "github.com/nats-io/go-nats/bench" + "github.com/nats-io/nats.go" + "github.com/nats-io/nats.go/bench" ) // Some sane defaults diff --git a/examples/nats-echo/main.go b/examples/nats-echo/main.go index 2ef011c48..d7c867ba5 100644 --- a/examples/nats-echo/main.go +++ b/examples/nats-echo/main.go @@ -1,4 +1,4 @@ -// Copyright 2018 The NATS Authors +// Copyright 2018-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -26,7 +26,7 @@ import ( "syscall" "time" - "github.com/nats-io/go-nats" + "github.com/nats-io/nats.go" ) // NOTE: Can test with demo servers. diff --git a/examples/nats-pub/main.go b/examples/nats-pub/main.go index ae37e1a9c..1244edaaa 100644 --- a/examples/nats-pub/main.go +++ b/examples/nats-pub/main.go @@ -1,4 +1,4 @@ -// Copyright 2012-2018 The NATS Authors +// Copyright 2012-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -17,7 +17,7 @@ import ( "flag" "log" - "github.com/nats-io/go-nats" + "github.com/nats-io/nats.go" ) // NOTE: Can test with demo servers. diff --git a/examples/nats-qsub/main.go b/examples/nats-qsub/main.go index 38274e433..fa03df1e4 100644 --- a/examples/nats-qsub/main.go +++ b/examples/nats-qsub/main.go @@ -1,4 +1,4 @@ -// Copyright 2012-2018 The NATS Authors +// Copyright 2012-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -20,7 +20,7 @@ import ( "runtime" "time" - "github.com/nats-io/go-nats" + "github.com/nats-io/nats.go" ) // NOTE: Can test with demo servers. diff --git a/examples/nats-req/main.go b/examples/nats-req/main.go index 33198fd6a..b7ddc3d24 100644 --- a/examples/nats-req/main.go +++ b/examples/nats-req/main.go @@ -1,4 +1,4 @@ -// Copyright 2012-2018 The NATS Authors +// Copyright 2012-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -18,7 +18,7 @@ import ( "log" "time" - "github.com/nats-io/go-nats" + "github.com/nats-io/nats.go" ) // NOTE: Can test with demo servers. @@ -59,7 +59,7 @@ func main() { defer nc.Close() subj, payload := args[0], []byte(args[1]) - msg, err := nc.Request(subj, []byte(payload), time.Second) + msg, err := nc.Request(subj, []byte(payload), 2*time.Second) if err != nil { if nc.LastError() != nil { log.Fatalf("%v for request", nc.LastError()) diff --git a/examples/nats-rply/main.go b/examples/nats-rply/main.go index 0a020d202..49fc7a515 100644 --- a/examples/nats-rply/main.go +++ b/examples/nats-rply/main.go @@ -1,4 +1,4 @@ -// Copyright 2012-2018 The NATS Authors +// Copyright 2012-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -19,7 +19,7 @@ import ( "runtime" "time" - "github.com/nats-io/go-nats" + "github.com/nats-io/nats.go" ) // NOTE: Can test with demo servers. diff --git a/examples/nats-sub/main.go b/examples/nats-sub/main.go index 4e4826a50..cb5023134 100644 --- a/examples/nats-sub/main.go +++ b/examples/nats-sub/main.go @@ -1,4 +1,4 @@ -// Copyright 2012-2018 The NATS Authors +// Copyright 2012-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -19,7 +19,7 @@ import ( "runtime" "time" - "github.com/nats-io/go-nats" + "github.com/nats-io/nats.go" ) // NOTE: Can test with demo servers. diff --git a/go.mod b/go.mod new file mode 100644 index 000000000..608c0436d --- /dev/null +++ b/go.mod @@ -0,0 +1,13 @@ +module github.com/nats-io/nats.go + +require ( + github.com/golang/protobuf v1.3.1 + github.com/nats-io/nats-server v1.4.1 + github.com/nats-io/nkeys v0.0.2 + github.com/nats-io/nuid v1.0.1 + golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529 // indirect + golang.org/x/net v0.0.0-20190509222800-a4d6f7feada5 // indirect + golang.org/x/sys v0.0.0-20190509141414-a5b02f93d862 // indirect + golang.org/x/text v0.3.2 // indirect + golang.org/x/tools v0.0.0-20190510151030-63859f3815cb // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 000000000..958bd2cf9 --- /dev/null +++ b/go.sum @@ -0,0 +1,25 @@ +github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/nats-io/nats-server v1.4.1 h1:Ul1oSOGNV/L8kjr4v6l2f9Yet6WY+LevH1/7cRZ/qyA= +github.com/nats-io/nats-server v1.4.1/go.mod h1:c8f/fHd2B6Hgms3LtCaI7y6pC4WD1f4SUxcCud5vhBc= +github.com/nats-io/nkeys v0.0.2 h1:+qM7QpgXnvDDixitZtQUBDY9w/s9mu1ghS+JIbsrx6M= +github.com/nats-io/nkeys v0.0.2/go.mod h1:dab7URMsZm6Z/jp9Z5UGa87Uutgc2mVpXLC4B7TDb/4= +github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw= +github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= +golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9 h1:mKdxBk7AujPs8kU4m80U72y/zjbZ3UcXC7dClwKbUI0= +golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529 h1:iMGN4xG0cnqj3t+zOM8wUB0BiPKHEwSxEZCvzcbZuvk= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190509222800-a4d6f7feada5/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190509141414-a5b02f93d862 h1:rM0ROo5vb9AdYJi1110yjWGMej9ITfKddS89P3Fkhug= +golang.org/x/sys v0.0.0-20190509141414-a5b02f93d862/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190510151030-63859f3815cb/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= diff --git a/nats.go b/nats.go index 48bf4801a..a91afc939 100644 --- a/nats.go +++ b/nats.go @@ -36,7 +36,7 @@ import ( "sync/atomic" "time" - "github.com/nats-io/go-nats/util" + "github.com/nats-io/nats.go/util" "github.com/nats-io/nkeys" "github.com/nats-io/nuid" ) diff --git a/nats_test.go b/nats_test.go index b1ecb9ea7..2764ad63d 100644 --- a/nats_test.go +++ b/nats_test.go @@ -1,4 +1,4 @@ -// Copyright 2012-2018 The NATS Authors +// Copyright 2012-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -104,7 +104,7 @@ func TestVersionMatchesTag(t *testing.T) { const TEST_PORT = 8368 var reconnectOpts = Options{ - Url: fmt.Sprintf("nats://localhost:%d", TEST_PORT), + Url: fmt.Sprintf("nats://127.0.0.1:%d", TEST_PORT), AllowReconnect: true, MaxReconnect: 10, ReconnectWait: 100 * time.Millisecond, @@ -1716,7 +1716,7 @@ func TestSubscribeSyncRace(t *testing.T) { s := RunServerOnPort(TEST_PORT) defer s.Shutdown() - nc, err := Connect(fmt.Sprintf("localhost:%d", TEST_PORT)) + nc, err := Connect(fmt.Sprintf("127.0.0.1:%d", TEST_PORT)) if err != nil { t.Fatalf("Error on connect: %v", err) } @@ -1742,11 +1742,11 @@ func BenchmarkNextMsgNoTimeout(b *testing.B) { s := RunServerOnPort(TEST_PORT) defer s.Shutdown() - ncp, err := Connect(fmt.Sprintf("localhost:%d", TEST_PORT)) + ncp, err := Connect(fmt.Sprintf("127.0.0.1:%d", TEST_PORT)) if err != nil { b.Fatalf("Error connecting: %v", err) } - ncs, err := Connect(fmt.Sprintf("localhost:%d", TEST_PORT), SyncQueueLen(b.N)) + ncs, err := Connect(fmt.Sprintf("127.0.0.1:%d", TEST_PORT), SyncQueueLen(b.N)) if err != nil { b.Fatalf("Error connecting: %v", err) } diff --git a/scripts/cov.sh b/scripts/cov.sh index 8760dfab5..398b4657d 100755 --- a/scripts/cov.sh +++ b/scripts/cov.sh @@ -4,9 +4,9 @@ rm -rf ./cov mkdir cov go test -v -race -covermode=atomic -coverprofile=./cov/nats.out -go test -v -race -covermode=atomic -coverprofile=./cov/test.out -coverpkg=github.com/nats-io/go-nats ./test -go test -v -race -covermode=atomic -coverprofile=./cov/builtin.out -coverpkg=github.com/nats-io/go-nats/encoders/builtin ./test -run EncBuiltin -go test -v -race -covermode=atomic -coverprofile=./cov/protobuf.out -coverpkg=github.com/nats-io/go-nats/encoders/protobuf ./test -run EncProto +go test -v -race -covermode=atomic -coverprofile=./cov/test.out -coverpkg=github.com/nats-io/nats.go ./test +go test -v -race -covermode=atomic -coverprofile=./cov/builtin.out -coverpkg=github.com/nats-io/nats.go/encoders/builtin ./test -run EncBuiltin +go test -v -race -covermode=atomic -coverprofile=./cov/protobuf.out -coverpkg=github.com/nats-io/nats.go/encoders/protobuf ./test -run EncProto gocovmerge ./cov/*.out > acc.out rm -rf ./cov diff --git a/staticcheck.ignore b/staticcheck.ignore index 25bbf0209..01d07d66e 100644 --- a/staticcheck.ignore +++ b/staticcheck.ignore @@ -1,4 +1,4 @@ -github.com/nats-io/go-nats/*_test.go:SA2002 -github.com/nats-io/go-nats/*/*_test.go:SA2002 -github.com/nats-io/go-nats/test/context_test.go:SA1012 -github.com/nats-io/go-nats/nats.go:SA6000 +github.com/nats-io/nats.go/*_test.go:SA2002 +github.com/nats-io/nats.go/*/*_test.go:SA2002 +github.com/nats-io/nats.go/test/context_test.go:SA1012 +github.com/nats-io/nats.go/nats.go:SA6000 diff --git a/test/auth_test.go b/test/auth_test.go index 394ae1f6d..7782dae5c 100644 --- a/test/auth_test.go +++ b/test/auth_test.go @@ -1,4 +1,4 @@ -// Copyright 2012-2018 The NATS Authors +// Copyright 2012-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -20,9 +20,9 @@ import ( "testing" "time" - "github.com/nats-io/go-nats" "github.com/nats-io/nats-server/server" "github.com/nats-io/nats-server/test" + "github.com/nats-io/nats.go" ) func TestAuth(t *testing.T) { @@ -33,7 +33,7 @@ func TestAuth(t *testing.T) { s := RunServerWithOptions(opts) defer s.Shutdown() - _, err := nats.Connect("nats://localhost:8232") + _, err := nats.Connect("nats://127.0.0.1:8232") if err == nil { t.Fatal("Should have received an error while trying to connect") } @@ -44,20 +44,20 @@ func TestAuth(t *testing.T) { t.Fatalf("Expected error '%v', got '%v'", nats.ErrAuthorization, err) } - nc, err := nats.Connect("nats://derek:foo@localhost:8232") + nc, err := nats.Connect("nats://derek:foo@127.0.0.1:8232") if err != nil { t.Fatal("Should have connected successfully with a token") } nc.Close() // Use Options - nc, err = nats.Connect("nats://localhost:8232", nats.UserInfo("derek", "foo")) + nc, err = nats.Connect("nats://127.0.0.1:8232", nats.UserInfo("derek", "foo")) if err != nil { t.Fatalf("Should have connected successfully with a token: %v", err) } nc.Close() // Verify that credentials in URL take precedence. - nc, err = nats.Connect("nats://derek:foo@localhost:8232", nats.UserInfo("foo", "bar")) + nc, err = nats.Connect("nats://derek:foo@127.0.0.1:8232", nats.UserInfo("foo", "bar")) if err != nil { t.Fatalf("Should have connected successfully with a token: %v", err) } @@ -73,7 +73,7 @@ func TestAuthFailNoDisconnectCB(t *testing.T) { defer s.Shutdown() copts := nats.GetDefaultOptions() - copts.Url = "nats://localhost:8232" + copts.Url = "nats://127.0.0.1:8232" receivedDisconnectCB := int32(0) copts.DisconnectedCB = func(nc *nats.Conn) { atomic.AddInt32(&receivedDisconnectCB, 1) @@ -93,9 +93,9 @@ func TestAuthFailAllowReconnect(t *testing.T) { defer ts.Shutdown() var servers = []string{ - "nats://localhost:23232", - "nats://localhost:23233", - "nats://localhost:23234", + "nats://127.0.0.1:23232", + "nats://127.0.0.1:23233", + "nats://127.0.0.1:23234", } opts2 := test.DefaultTestOptions @@ -151,8 +151,8 @@ func TestAuthFailAllowReconnect(t *testing.T) { func TestTokenHandlerReconnect(t *testing.T) { var servers = []string{ - "nats://localhost:8232", - "nats://localhost:8233", + "nats://127.0.0.1:8232", + "nats://127.0.0.1:8233", } ts := RunServerOnPort(8232) @@ -217,12 +217,12 @@ func TestTokenAuth(t *testing.T) { s := RunServerWithOptions(opts) defer s.Shutdown() - _, err := nats.Connect("nats://localhost:8232") + _, err := nats.Connect("nats://127.0.0.1:8232") if err == nil { t.Fatal("Should have received an error while trying to connect") } - tokenURL := fmt.Sprintf("nats://%s@localhost:8232", secret) + tokenURL := fmt.Sprintf("nats://%s@127.0.0.1:8232", secret) nc, err := nats.Connect(tokenURL) if err != nil { t.Fatal("Should have connected successfully") @@ -230,18 +230,18 @@ func TestTokenAuth(t *testing.T) { nc.Close() // Use Options - nc, err = nats.Connect("nats://localhost:8232", nats.Token(secret)) + nc, err = nats.Connect("nats://127.0.0.1:8232", nats.Token(secret)) if err != nil { t.Fatalf("Should have connected successfully: %v", err) } nc.Close() // Verify that token cannot be set when token handler is provided. - _, err = nats.Connect("nats://localhost:8232", nats.TokenHandler(func() string { return secret }), nats.Token(secret)) + _, err = nats.Connect("nats://127.0.0.1:8232", nats.TokenHandler(func() string { return secret }), nats.Token(secret)) if err == nil { t.Fatal("Should have received an error while trying to connect") } // Verify that token handler cannot be provided when token is set. - _, err = nats.Connect("nats://localhost:8232", nats.Token(secret), nats.TokenHandler(func() string { return secret })) + _, err = nats.Connect("nats://127.0.0.1:8232", nats.Token(secret), nats.TokenHandler(func() string { return secret })) if err == nil { t.Fatal("Should have received an error while trying to connect") } @@ -261,12 +261,12 @@ func TestTokenHandlerAuth(t *testing.T) { s := RunServerWithOptions(opts) defer s.Shutdown() - _, err := nats.Connect("nats://localhost:8232") + _, err := nats.Connect("nats://127.0.0.1:8232") if err == nil { t.Fatal("Should have received an error while trying to connect") } - tokenURL := fmt.Sprintf("nats://%s@localhost:8232", secret) + tokenURL := fmt.Sprintf("nats://%s@127.0.0.1:8232", secret) nc, err := nats.Connect(tokenURL) if err != nil { t.Fatal("Should have connected successfully") @@ -274,18 +274,18 @@ func TestTokenHandlerAuth(t *testing.T) { nc.Close() // Use Options - nc, err = nats.Connect("nats://localhost:8232", nats.TokenHandler(func() string { return secret })) + nc, err = nats.Connect("nats://127.0.0.1:8232", nats.TokenHandler(func() string { return secret })) if err != nil { t.Fatalf("Should have connected successfully: %v", err) } nc.Close() // Verify that token cannot be set when token handler is provided. - _, err = nats.Connect("nats://localhost:8232", nats.TokenHandler(func() string { return secret }), nats.Token(secret)) + _, err = nats.Connect("nats://127.0.0.1:8232", nats.TokenHandler(func() string { return secret }), nats.Token(secret)) if err == nil { t.Fatal("Should have received an error while trying to connect") } // Verify that token handler cannot be provided when token is set. - _, err = nats.Connect("nats://localhost:8232", nats.Token(secret), nats.TokenHandler(func() string { return secret })) + _, err = nats.Connect("nats://127.0.0.1:8232", nats.Token(secret), nats.TokenHandler(func() string { return secret })) if err == nil { t.Fatal("Should have received an error while trying to connect") } @@ -317,7 +317,7 @@ func TestPermViolation(t *testing.T) { errCh <- err } nc, err := nats.Connect( - fmt.Sprintf("nats://ivan:pwd@localhost:%d", opts.Port), + fmt.Sprintf("nats://ivan:pwd@127.0.0.1:%d", opts.Port), nats.ErrorHandler(errCB)) if err != nil { t.Fatalf("Error on connect: %v", err) diff --git a/test/basic_test.go b/test/basic_test.go index 2af38d1a5..7d05cc192 100644 --- a/test/basic_test.go +++ b/test/basic_test.go @@ -1,4 +1,4 @@ -// Copyright 2012-2018 The NATS Authors +// Copyright 2012-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -24,7 +24,7 @@ import ( "testing" "time" - "github.com/nats-io/go-nats" + "github.com/nats-io/nats.go" ) // This function returns the number of go routines ensuring @@ -144,7 +144,7 @@ func TestBadOptionTimeoutConnect(t *testing.T) { opts := nats.GetDefaultOptions() opts.Timeout = -1 - opts.Url = "nats://localhost:4222" + opts.Url = "nats://127.0.0.1:4222" _, err := opts.Connect() if err == nil { diff --git a/test/bench_test.go b/test/bench_test.go index f7b40414d..ca7dc3b8b 100644 --- a/test/bench_test.go +++ b/test/bench_test.go @@ -1,4 +1,4 @@ -// Copyright 2012-2018 The NATS Authors +// Copyright 2012-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -18,7 +18,7 @@ import ( "testing" "time" - "github.com/nats-io/go-nats" + "github.com/nats-io/nats.go" ) func BenchmarkPublishSpeed(b *testing.B) { diff --git a/test/cluster_test.go b/test/cluster_test.go index 336b4031e..1aca76165 100644 --- a/test/cluster_test.go +++ b/test/cluster_test.go @@ -1,4 +1,4 @@ -// Copyright 2012-2018 The NATS Authors +// Copyright 2012-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -23,19 +23,19 @@ import ( "testing" "time" - "github.com/nats-io/go-nats" "github.com/nats-io/nats-server/server" "github.com/nats-io/nats-server/test" + "github.com/nats-io/nats.go" ) var testServers = []string{ - "nats://localhost:1222", - "nats://localhost:1223", - "nats://localhost:1224", - "nats://localhost:1225", - "nats://localhost:1226", - "nats://localhost:1227", - "nats://localhost:1228", + "nats://127.0.0.1:1222", + "nats://127.0.0.1:1223", + "nats://127.0.0.1:1224", + "nats://127.0.0.1:1225", + "nats://127.0.0.1:1226", + "nats://127.0.0.1:1227", + "nats://127.0.0.1:1228", } var servers = strings.Join(testServers, ",") @@ -74,7 +74,7 @@ func TestServersOption(t *testing.T) { if err != nil { t.Fatalf("Could not connect: %v\n", err) } - if nc.ConnectedUrl() != "nats://localhost:1222" { + if nc.ConnectedUrl() != "nats://127.0.0.1:1222" { nc.Close() t.Fatalf("Does not report correct connection: %s\n", nc.ConnectedUrl()) @@ -92,7 +92,7 @@ func TestServersOption(t *testing.T) { t.Fatalf("Could not connect: %v\n", err) } defer nc.Close() - if nc.ConnectedUrl() != "nats://localhost:1223" { + if nc.ConnectedUrl() != "nats://127.0.0.1:1223" { t.Fatalf("Does not report correct connection: %s\n", nc.ConnectedUrl()) } @@ -119,7 +119,7 @@ func TestNewStyleServersOption(t *testing.T) { if err != nil { t.Fatalf("Could not connect: %v\n", err) } - if nc.ConnectedUrl() != "nats://localhost:1222" { + if nc.ConnectedUrl() != "nats://127.0.0.1:1222" { nc.Close() t.Fatalf("Does not report correct connection: %s\n", nc.ConnectedUrl()) @@ -137,7 +137,7 @@ func TestNewStyleServersOption(t *testing.T) { t.Fatalf("Could not connect: %v\n", err) } defer nc.Close() - if nc.ConnectedUrl() != "nats://localhost:1223" { + if nc.ConnectedUrl() != "nats://127.0.0.1:1223" { t.Fatalf("Does not report correct connection: %s\n", nc.ConnectedUrl()) } @@ -145,8 +145,8 @@ func TestNewStyleServersOption(t *testing.T) { func TestAuthServers(t *testing.T) { var plainServers = []string{ - "nats://localhost:1222", - "nats://localhost:1224", + "nats://127.0.0.1:1222", + "nats://127.0.0.1:1224", } opts := test.DefaultTestOptions @@ -173,8 +173,8 @@ func TestAuthServers(t *testing.T) { // Test that we can connect to a subsequent correct server. var authServers = []string{ - "nats://localhost:1222", - "nats://derek:foo@localhost:1224", + "nats://127.0.0.1:1222", + "nats://derek:foo@127.0.0.1:1224", } aservers := strings.Join(authServers, ",") nc, err = nats.Connect(aservers, nats.DontRandomize(), nats.Timeout(5*time.Second)) @@ -438,8 +438,8 @@ func TestProperFalloutAfterMaxAttempts(t *testing.T) { func TestProperFalloutAfterMaxAttemptsWithAuthMismatch(t *testing.T) { var myServers = []string{ - "nats://localhost:1222", - "nats://localhost:4443", + "nats://127.0.0.1:1222", + "nats://127.0.0.1:4443", } s1 := RunServerOnPort(1222) defer s1.Shutdown() diff --git a/test/conn_test.go b/test/conn_test.go index 73e261965..2050e1941 100644 --- a/test/conn_test.go +++ b/test/conn_test.go @@ -1,4 +1,4 @@ -// Copyright 2012-2018 The NATS Authors +// Copyright 2012-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -29,9 +29,9 @@ import ( "testing" "time" - "github.com/nats-io/go-nats" "github.com/nats-io/nats-server/server" "github.com/nats-io/nats-server/test" + "github.com/nats-io/nats.go" ) func TestDefaultConnection(t *testing.T) { @@ -384,7 +384,7 @@ func TestErrOnConnectAndDeadlock(t *testing.T) { ch := make(chan bool) go func() { - natsURL := fmt.Sprintf("nats://localhost:%d/", addr.Port) + natsURL := fmt.Sprintf("nats://127.0.0.1:%d/", addr.Port) nc, err := nats.Connect(natsURL) if err == nil { nc.Close() @@ -480,7 +480,7 @@ func TestMoreErrOnConnect(t *testing.T) { <-done }() - natsURL := fmt.Sprintf("nats://localhost:%d", addr.Port) + natsURL := fmt.Sprintf("nats://127.0.0.1:%d", addr.Port) if nc, err := nats.Connect(natsURL, nats.Timeout(20*time.Millisecond)); err == nil { nc.Close() @@ -1514,7 +1514,7 @@ func TestNewServers(t *testing.T) { s1Opts := test.DefaultTestOptions s1Opts.Host = "127.0.0.1" s1Opts.Port = 4222 - s1Opts.Cluster.Host = "localhost" + s1Opts.Cluster.Host = "127.0.0.1" s1Opts.Cluster.Port = 6222 s1 := test.RunServer(&s1Opts) defer s1.Shutdown() @@ -1523,9 +1523,9 @@ func TestNewServers(t *testing.T) { s2Opts.Host = "127.0.0.1" s2Opts.Port = 4223 s2Opts.Port = s1Opts.Port + 1 - s2Opts.Cluster.Host = "localhost" + s2Opts.Cluster.Host = "127.0.0.1" s2Opts.Cluster.Port = 6223 - s2Opts.Routes = server.RoutesFromStr("nats://localhost:6222") + s2Opts.Routes = server.RoutesFromStr("nats://127.0.0.1:6222") s2 := test.RunServer(&s2Opts) defer s2.Shutdown() @@ -1568,9 +1568,9 @@ func TestNewServers(t *testing.T) { s1Opts.Host = "127.0.0.1" s1Opts.Port = 4224 s3Opts.Port = s2Opts.Port + 1 - s3Opts.Cluster.Host = "localhost" + s3Opts.Cluster.Host = "127.0.0.1" s3Opts.Cluster.Port = 6224 - s3Opts.Routes = server.RoutesFromStr("nats://localhost:6222") + s3Opts.Routes = server.RoutesFromStr("nats://127.0.0.1:6222") s3 := test.RunServer(&s3Opts) defer s3.Shutdown() diff --git a/test/context_test.go b/test/context_test.go index 64cc6781e..b5d23d6b4 100644 --- a/test/context_test.go +++ b/test/context_test.go @@ -21,7 +21,7 @@ import ( "testing" "time" - "github.com/nats-io/go-nats" + "github.com/nats-io/nats.go" ) func TestContextRequestWithNilConnection(t *testing.T) { diff --git a/test/drain_test.go b/test/drain_test.go index 477d06d53..b22583352 100644 --- a/test/drain_test.go +++ b/test/drain_test.go @@ -1,4 +1,4 @@ -// Copyright 2018 The NATS Authors +// Copyright 2018-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -20,7 +20,7 @@ import ( "testing" "time" - nats "github.com/nats-io/go-nats" + "github.com/nats-io/nats.go" ) // Drain can be very useful for graceful shutdown of subscribers. diff --git a/test/enc_test.go b/test/enc_test.go index a2a2ebe6b..1f82e60b0 100644 --- a/test/enc_test.go +++ b/test/enc_test.go @@ -1,4 +1,4 @@ -// Copyright 2012-2018 The NATS Authors +// Copyright 2012-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -18,8 +18,8 @@ import ( "testing" "time" - "github.com/nats-io/go-nats" - "github.com/nats-io/go-nats/encoders/builtin" + "github.com/nats-io/nats.go" + "github.com/nats-io/nats.go/encoders/builtin" ) const TEST_PORT = 8168 diff --git a/test/gob_test.go b/test/gob_test.go index 72992f862..c772e1074 100644 --- a/test/gob_test.go +++ b/test/gob_test.go @@ -1,4 +1,4 @@ -// Copyright 2012-2018 The NATS Authors +// Copyright 2012-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -17,7 +17,7 @@ import ( "reflect" "testing" - "github.com/nats-io/go-nats" + "github.com/nats-io/nats.go" ) func NewGobEncodedConn(tl TestLogger) *nats.EncodedConn { diff --git a/test/helper_test.go b/test/helper_test.go index b1cf1df96..a09453fca 100644 --- a/test/helper_test.go +++ b/test/helper_test.go @@ -1,4 +1,4 @@ -// Copyright 2015-2018 The NATS Authors +// Copyright 2015-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -20,8 +20,8 @@ import ( "strings" "time" - "github.com/nats-io/go-nats" "github.com/nats-io/nats-server/server" + "github.com/nats-io/nats.go" natsserver "github.com/nats-io/nats-server/test" ) diff --git a/test/json_test.go b/test/json_test.go index 651e93a37..c90718430 100644 --- a/test/json_test.go +++ b/test/json_test.go @@ -1,4 +1,4 @@ -// Copyright 2012-2018 The NATS Authors +// Copyright 2012-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -18,8 +18,8 @@ import ( "testing" "time" - "github.com/nats-io/go-nats" - "github.com/nats-io/go-nats/encoders/builtin" + "github.com/nats-io/nats.go" + "github.com/nats-io/nats.go/encoders/builtin" ) func NewJsonEncodedConn(tl TestLogger) *nats.EncodedConn { diff --git a/test/netchan_test.go b/test/netchan_test.go index 23c22834b..70d71cfb8 100644 --- a/test/netchan_test.go +++ b/test/netchan_test.go @@ -1,4 +1,4 @@ -// Copyright 2013-2018 The NATS Authors +// Copyright 2013-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -19,7 +19,7 @@ import ( "testing" "time" - "github.com/nats-io/go-nats" + "github.com/nats-io/nats.go" ) func TestBadChan(t *testing.T) { diff --git a/test/protobuf_test.go b/test/protobuf_test.go index 03c95d59e..bfca36b3f 100644 --- a/test/protobuf_test.go +++ b/test/protobuf_test.go @@ -1,4 +1,4 @@ -// Copyright 2015-2018 The NATS Authors +// Copyright 2015-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -18,10 +18,10 @@ import ( "testing" "time" - "github.com/nats-io/go-nats" + "github.com/nats-io/nats.go" - "github.com/nats-io/go-nats/encoders/protobuf" - pb "github.com/nats-io/go-nats/encoders/protobuf/testdata" + "github.com/nats-io/nats.go/encoders/protobuf" + pb "github.com/nats-io/nats.go/encoders/protobuf/testdata" ) func NewProtoEncodedConn(tl TestLogger) *nats.EncodedConn { diff --git a/test/reconnect_test.go b/test/reconnect_test.go index 17190d854..be4c91d57 100644 --- a/test/reconnect_test.go +++ b/test/reconnect_test.go @@ -1,4 +1,4 @@ -// Copyright 2013-2018 The NATS Authors +// Copyright 2013-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -22,8 +22,8 @@ import ( "testing" "time" - "github.com/nats-io/go-nats" "github.com/nats-io/nats-server/server" + "github.com/nats-io/nats.go" ) func startReconnectServer(t *testing.T) *server.Server { @@ -45,7 +45,7 @@ func TestReconnectDisallowedFlags(t *testing.T) { ch := make(chan bool) opts := nats.GetDefaultOptions() - opts.Url = "nats://localhost:22222" + opts.Url = "nats://127.0.0.1:22222" opts.AllowReconnect = false opts.ClosedCB = func(_ *nats.Conn) { ch <- true @@ -69,7 +69,7 @@ func TestReconnectAllowedFlags(t *testing.T) { ch := make(chan bool) dch := make(chan bool) opts := nats.GetDefaultOptions() - opts.Url = "nats://localhost:22222" + opts.Url = "nats://127.0.0.1:22222" opts.AllowReconnect = true opts.MaxReconnect = 2 opts.ReconnectWait = 1 * time.Second @@ -109,7 +109,7 @@ func TestReconnectAllowedFlags(t *testing.T) { } var reconnectOpts = nats.Options{ - Url: "nats://localhost:22222", + Url: "nats://127.0.0.1:22222", AllowReconnect: true, MaxReconnect: 10, ReconnectWait: 100 * time.Millisecond, @@ -431,7 +431,7 @@ func TestIsReconnectingAndStatus(t *testing.T) { disconnectedch := make(chan bool) reconnectch := make(chan bool) opts := nats.GetDefaultOptions() - opts.Url = "nats://localhost:22222" + opts.Url = "nats://127.0.0.1:22222" opts.AllowReconnect = true opts.MaxReconnect = 10000 opts.ReconnectWait = 100 * time.Millisecond @@ -500,7 +500,7 @@ func TestFullFlushChanDuringReconnect(t *testing.T) { reconnectch := make(chan bool) opts := nats.GetDefaultOptions() - opts.Url = "nats://localhost:22222" + opts.Url = "nats://127.0.0.1:22222" opts.AllowReconnect = true opts.MaxReconnect = 10000 opts.ReconnectWait = 100 * time.Millisecond @@ -596,7 +596,7 @@ func TestReconnectBufSizeOption(t *testing.T) { s := RunDefaultServer() defer s.Shutdown() - nc, err := nats.Connect("nats://localhost:4222", nats.ReconnectBufSize(32)) + nc, err := nats.Connect("nats://127.0.0.1:4222", nats.ReconnectBufSize(32)) if err != nil { t.Fatalf("Should have connected ok: %v", err) } diff --git a/test/sub_test.go b/test/sub_test.go index e70ac3695..bbd3882e8 100644 --- a/test/sub_test.go +++ b/test/sub_test.go @@ -1,4 +1,4 @@ -// Copyright 2013-2018 The NATS Authors +// Copyright 2013-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -21,7 +21,7 @@ import ( "testing" "time" - "github.com/nats-io/go-nats" + "github.com/nats-io/nats.go" ) // More advanced tests on subscriptions