You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2015/12/30 22:13:36 UTC
[48/50] [abbrv] qpid-proton git commit: NO-JIRA: Update go-get repo
to work with 0.10, 0.11 and master proton C libraries.
NO-JIRA: Update go-get repo to work with 0.10, 0.11 and master proton C libraries.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/bf7e1930
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/bf7e1930
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/bf7e1930
Branch: refs/heads/go1
Commit: bf7e19309c1ee0f6fdac058ce998cdd2a1ee403d
Parents: 117bb7c
Author: Alan Conway <ac...@redhat.com>
Authored: Wed Dec 30 15:58:26 2015 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Wed Dec 30 15:58:26 2015 -0500
----------------------------------------------------------------------
examples/go/README.md | 23 +++++++-------
examples/go/example_test.go | 2 +-
proton-c/bindings/go/genwrap.go | 2 ++
.../go/src/qpid.apache.org/amqp/codec_shim.h | 33 ++++++++++++++++++++
.../go/src/qpid.apache.org/amqp/marshal.go | 2 +-
.../go/src/qpid.apache.org/amqp/message.go | 2 +-
.../go/src/qpid.apache.org/amqp/types.go | 11 ++-----
.../go/src/qpid.apache.org/amqp/unmarshal.go | 6 ++--
.../go/src/qpid.apache.org/proton/engine.go | 1 +
.../src/qpid.apache.org/proton/wrappers_gen.go | 2 ++
10 files changed, 58 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bf7e1930/examples/go/README.md
----------------------------------------------------------------------
diff --git a/examples/go/README.md b/examples/go/README.md
index ce9206b..9ba497b 100644
--- a/examples/go/README.md
+++ b/examples/go/README.md
@@ -24,23 +24,22 @@ proton
## Using the Go packages
-Use `go get qpid.apache.org/electron` or check out the proton repository and set
-your GOPATH environment variable to include
-`/<path-to-proton>/proton-c/bindings/go`
+If you have the proton C library and headers installed you can get the latest go
+packages with
-The proton Go packages include C code so the cgo compiler needs to be able to
-find the proton library and include files. There are a couple of ways to do
-this:
+ go get qpid.apache.org/electron
-1. Build proton in directory `$BUILD`. Source the script `$BUILD/config.sh` to set your environment.
+If proton is installed in a non-standard place (other than /usr or /usr/local) you
+can set these environment variables before `go get`, for example:
-2. Install proton to a standard prefix such as `/usr` or `/usr/local`. No need for further settings.
+ export CGO_LDFLAGS="-L/<my-proton>/lib[64]"
+ export CGO_CFLAGS="-I/<my-proton>/include"
+ go get qpid.apache.org/electron
-3. Install proton to a non-standard prefix `$PREFIX`. Set the following:
+If you have a proton build you don't need to `go get`, you can set your GOPATH
+to use the binding from the checkout with:
- export LIBRARY_PATH=$PREFIX/lib:$LIBRARY_PATH
- export C_INCLUDE_PATH=$PREFIX/include:$C_INCLUDE_PATH
- export LD_LIBRARY_PATH=$PREFIX/lib:$LD_LIBRARY_PATH
+ source <path-to-proton>/config.sh
Once you are set up, the go tools will work as normal. You can see documentation
in your web browser at `localhost:6060` by running:
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bf7e1930/examples/go/example_test.go
----------------------------------------------------------------------
diff --git a/examples/go/example_test.go b/examples/go/example_test.go
index 006e17c..6de309e 100644
--- a/examples/go/example_test.go
+++ b/examples/go/example_test.go
@@ -258,7 +258,7 @@ var debug = flag.Bool("debug", false, "Debugging output from examples")
var brokerName = flag.String("broker", "broker", "Name of broker executable to run")
var count = flag.Int("count", 3, "Count of messages to send in tests")
var connections = flag.Int("connections", 3, "Number of connections to make in tests")
-var dir = flag.String("dir", "", "Directory containing example sources or binaries")
+var dir = flag.String("dir", "electron", "Directory containing example sources or binaries")
var expected int
func TestMain(m *testing.M) {
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bf7e1930/proton-c/bindings/go/genwrap.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/genwrap.go b/proton-c/bindings/go/genwrap.go
index fe383a9..c904638 100644
--- a/proton-c/bindings/go/genwrap.go
+++ b/proton-c/bindings/go/genwrap.go
@@ -55,6 +55,8 @@ import (
)
// #include <proton/types.h>
+// #include <proton/error.h>
+// #include <proton/condition.h>
// #include <proton/event.h>
// #include <stdlib.h>
`)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bf7e1930/proton-c/bindings/go/src/qpid.apache.org/amqp/codec_shim.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/amqp/codec_shim.h b/proton-c/bindings/go/src/qpid.apache.org/amqp/codec_shim.h
new file mode 100644
index 0000000..b2f9f1c
--- /dev/null
+++ b/proton-c/bindings/go/src/qpid.apache.org/amqp/codec_shim.h
@@ -0,0 +1,33 @@
+#ifndef CODEC_SHIM_H
+#define CODEC_SHIM_H
+/*
+ * 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.
+ */
+
+/** Stubs to allow the go binding to work with multiple versions of proton. */
+
+#include <proton/codec.h>
+#include <proton/version.h>
+
+#if PN_VERSION_MAJOR == 0 && PN_VERSION_MINOR <= 10
+
+#define PN_INVALID ((pn_type_t)-1)
+
+#endif
+
+#endif // CODEC_SHIM_H
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bf7e1930/proton-c/bindings/go/src/qpid.apache.org/amqp/marshal.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/amqp/marshal.go b/proton-c/bindings/go/src/qpid.apache.org/amqp/marshal.go
index 9930e13..66e14d8 100644
--- a/proton-c/bindings/go/src/qpid.apache.org/amqp/marshal.go
+++ b/proton-c/bindings/go/src/qpid.apache.org/amqp/marshal.go
@@ -19,7 +19,7 @@ under the License.
package amqp
-// #include <proton/codec.h>
+//#include "codec_shim.h"
import "C"
import (
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bf7e1930/proton-c/bindings/go/src/qpid.apache.org/amqp/message.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/amqp/message.go b/proton-c/bindings/go/src/qpid.apache.org/amqp/message.go
index e36c6f2..1d1287f 100644
--- a/proton-c/bindings/go/src/qpid.apache.org/amqp/message.go
+++ b/proton-c/bindings/go/src/qpid.apache.org/amqp/message.go
@@ -19,9 +19,9 @@ under the License.
package amqp
+// #include "codec_shim.h"
// #include <proton/types.h>
// #include <proton/message.h>
-// #include <proton/codec.h>
// #include <stdlib.h>
//
// /* Helper for setting message string fields */
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bf7e1930/proton-c/bindings/go/src/qpid.apache.org/amqp/types.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/amqp/types.go b/proton-c/bindings/go/src/qpid.apache.org/amqp/types.go
index 697d896..d927cc5 100644
--- a/proton-c/bindings/go/src/qpid.apache.org/amqp/types.go
+++ b/proton-c/bindings/go/src/qpid.apache.org/amqp/types.go
@@ -19,7 +19,7 @@ under the License.
package amqp
-// #include <proton/codec.h>
+//#include "codec_shim.h"
import "C"
import (
@@ -30,10 +30,6 @@ import (
"unsafe"
)
-// Older proton versions don't define C.PN_INVALID, so define it here.
-// In C it is pn_type_t(-1), in Go use the bitwise NOT operator to get the same value.
-const pnInvalid = C.pn_type_t(^0)
-
func (t C.pn_type_t) String() string {
switch C.pn_type_t(t) {
case C.PN_NULL:
@@ -86,10 +82,9 @@ func (t C.pn_type_t) String() string {
return "list"
case C.PN_MAP:
return "map"
+ case C.PN_INVALID:
+ return "no-data"
default:
- if t == pnInvalid {
- return "no-data"
- }
return fmt.Sprintf("unknown-type(%d)", t)
}
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bf7e1930/proton-c/bindings/go/src/qpid.apache.org/amqp/unmarshal.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/amqp/unmarshal.go b/proton-c/bindings/go/src/qpid.apache.org/amqp/unmarshal.go
index 05ecb8d..6942174 100644
--- a/proton-c/bindings/go/src/qpid.apache.org/amqp/unmarshal.go
+++ b/proton-c/bindings/go/src/qpid.apache.org/amqp/unmarshal.go
@@ -19,7 +19,7 @@ under the License.
package amqp
-// #include <proton/codec.h>
+// #include "codec_shim.h"
import "C"
import (
@@ -451,7 +451,7 @@ func rewindUnmarshal(v interface{}, data *C.pn_data_t) {
func getInterface(data *C.pn_data_t, v *interface{}) {
pnType := C.pn_data_type(data)
switch pnType {
- case C.PN_NULL, pnInvalid: // No data.
+ case C.PN_NULL, C.PN_INVALID: // No data.
*v = nil
case C.PN_BOOL:
*v = bool(C.pn_data_get_bool(data))
@@ -517,7 +517,7 @@ func getMap(data *C.pn_data_t, v interface{}) {
}
}
}
- case pnInvalid: // Leave the map empty
+ case C.PN_INVALID: // Leave the map empty
default:
panic(newUnmarshalError(pnType, v))
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bf7e1930/proton-c/bindings/go/src/qpid.apache.org/proton/engine.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/proton/engine.go b/proton-c/bindings/go/src/qpid.apache.org/proton/engine.go
index 95d70e9..13d44b8 100644
--- a/proton-c/bindings/go/src/qpid.apache.org/proton/engine.go
+++ b/proton-c/bindings/go/src/qpid.apache.org/proton/engine.go
@@ -21,6 +21,7 @@ package proton
// #include <proton/connection.h>
// #include <proton/event.h>
+// #include <proton/error.h>
// #include <proton/handlers.h>
// #include <proton/session.h>
// #include <proton/transport.h>
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bf7e1930/proton-c/bindings/go/src/qpid.apache.org/proton/wrappers_gen.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/proton/wrappers_gen.go b/proton-c/bindings/go/src/qpid.apache.org/proton/wrappers_gen.go
index c69b2a8..183d6ec 100644
--- a/proton-c/bindings/go/src/qpid.apache.org/proton/wrappers_gen.go
+++ b/proton-c/bindings/go/src/qpid.apache.org/proton/wrappers_gen.go
@@ -30,6 +30,8 @@ import (
)
// #include <proton/types.h>
+// #include <proton/error.h>
+// #include <proton/condition.h>
// #include <proton/event.h>
// #include <stdlib.h>
// #include <proton/session.h>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org