NO-JIRA: Fix go vet -v warnings, minor typos
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/f46076e4 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/f46076e4 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/f46076e4 Branch: refs/heads/master Commit: f46076e4c19f05584f1724ef52930821c8d66c38 Parents: 55b2735 Author: Alan Conway <acon...@redhat.com> Authored: Fri Oct 5 15:38:14 2018 -0400 Committer: Alan Conway <acon...@redhat.com> Committed: Thu Oct 11 12:33:08 2018 -0400 ---------------------------------------------------------------------- go/src/qpid.apache.org/amqp/types_test.go | 2 +- go/src/qpid.apache.org/electron/common_test.go | 2 +- go/src/qpid.apache.org/electron/connection.go | 5 ++- go/src/qpid.apache.org/electron/error.go | 35 --------------------- go/src/qpid.apache.org/electron/receiver.go | 8 +++-- go/src/qpid.apache.org/proton/error.go | 13 +------- 6 files changed, 12 insertions(+), 53 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f46076e4/go/src/qpid.apache.org/amqp/types_test.go ---------------------------------------------------------------------- diff --git a/go/src/qpid.apache.org/amqp/types_test.go b/go/src/qpid.apache.org/amqp/types_test.go index 8f7cd6a..994a3cd 100644 --- a/go/src/qpid.apache.org/amqp/types_test.go +++ b/go/src/qpid.apache.org/amqp/types_test.go @@ -44,7 +44,7 @@ func checkUnmarshal(marshaled []byte, v interface{}) error { return nil } -func ExampleKey() { +func ExampleAnnotationKey() { var k AnnotationKey = AnnotationKeySymbol(Symbol("foo")) fmt.Println(k.Get().(Symbol)) k = AnnotationKeyUint64(42) http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f46076e4/go/src/qpid.apache.org/electron/common_test.go ---------------------------------------------------------------------- diff --git a/go/src/qpid.apache.org/electron/common_test.go b/go/src/qpid.apache.org/electron/common_test.go index e2e4a2a..59fbfff 100644 --- a/go/src/qpid.apache.org/electron/common_test.go +++ b/go/src/qpid.apache.org/electron/common_test.go @@ -47,7 +47,7 @@ func fatalIf(t testing.TB, err error) { func errorIf(t testing.TB, err error) { if err != nil { - t.Errorf(decorate(err, 1)) + t.Error(decorate(err, 1)) } } http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f46076e4/go/src/qpid.apache.org/electron/connection.go ---------------------------------------------------------------------- diff --git a/go/src/qpid.apache.org/electron/connection.go b/go/src/qpid.apache.org/electron/connection.go index 628d933..48cba60 100644 --- a/go/src/qpid.apache.org/electron/connection.go +++ b/go/src/qpid.apache.org/electron/connection.go @@ -25,6 +25,7 @@ import "C" import ( "crypto/rand" "encoding/hex" + "fmt" "net" "sync" "time" @@ -310,7 +311,9 @@ func (c *connection) WaitTimeout(timeout time.Duration) error { } func (c *connection) Incoming() <-chan Incoming { - assert(c.incoming != nil, "Incoming() is only allowed for a Connection created with the Server() option: %s", c) + if c.incoming == nil { + panic(fmt.Errorf("Incoming() only allowed on Connection created with the Server() option: %s", c)) + } return c.incoming } http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f46076e4/go/src/qpid.apache.org/electron/error.go ---------------------------------------------------------------------- diff --git a/go/src/qpid.apache.org/electron/error.go b/go/src/qpid.apache.org/electron/error.go deleted file mode 100644 index 4dcfd94..0000000 --- a/go/src/qpid.apache.org/electron/error.go +++ /dev/null @@ -1,35 +0,0 @@ -/* -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you 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 - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. -*/ - -package electron - -import ( - "fmt" -) - -// assert panics if condition is false with optional formatted message -func assert(condition bool, format ...interface{}) { - if !condition { - if len(format) > 0 { - panic(fmt.Errorf(format[0].(string), format[1:]...)) - } else { - panic(fmt.Errorf("assertion failed")) - } - } -} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f46076e4/go/src/qpid.apache.org/electron/receiver.go ---------------------------------------------------------------------- diff --git a/go/src/qpid.apache.org/electron/receiver.go b/go/src/qpid.apache.org/electron/receiver.go index 26b46a8..8e3b1a7 100644 --- a/go/src/qpid.apache.org/electron/receiver.go +++ b/go/src/qpid.apache.org/electron/receiver.go @@ -21,9 +21,10 @@ package electron import ( "fmt" + "time" + "qpid.apache.org/amqp" "qpid.apache.org/proton" - "time" ) // Receiver is a Link that receives messages. @@ -126,7 +127,9 @@ func (r *receiver) Receive() (rm ReceivedMessage, err error) { } func (r *receiver) ReceiveTimeout(timeout time.Duration) (rm ReceivedMessage, err error) { - assert(r.buffer != nil, "Receiver is not open: %s", r) + if r.buffer == nil { + panic(fmt.Errorf("Receiver is not open: %s", r)) + } if !r.prefetch { // Per-caller flow control select { // Check for immediate availability, avoid caller() inject case rm2, ok := <-r.buffer: @@ -164,7 +167,6 @@ func (r *receiver) message(delivery proton.Delivery) { localClose(r.pLink, err) return } - assert(m != nil) r.pLink.Advance() if r.pLink.Credit() < 0 { localClose(r.pLink, fmt.Errorf("received message in excess of credit limit")) http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f46076e4/go/src/qpid.apache.org/proton/error.go ---------------------------------------------------------------------- diff --git a/go/src/qpid.apache.org/proton/error.go b/go/src/qpid.apache.org/proton/error.go index 5232fec..a6fb026 100644 --- a/go/src/qpid.apache.org/proton/error.go +++ b/go/src/qpid.apache.org/proton/error.go @@ -71,7 +71,7 @@ type ErrorHolder struct { value atomic.Value } -// Set the error if not already set, return the error in the Holder. +// Set the error if not already set func (e *ErrorHolder) Set(err error) { if err != nil { e.once.Do(func() { e.value.Store(err) }) @@ -83,14 +83,3 @@ func (e *ErrorHolder) Get() (err error) { err, _ = e.value.Load().(error) return } - -// assert panics if condition is false with optional formatted message -func assert(condition bool, format ...interface{}) { - if !condition { - if len(format) > 0 { - panic(fmt.Errorf(format[0].(string), format[1:]...)) - } else { - panic(fmt.Errorf("assertion failed")) - } - } -} --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org