Freshgomod (#106)

* initial go modules, fresh start to find breaking change

* change dep to go mod vendor

* main go modules done, tests passed locally

* upgrade go in dockerfileserver
This commit is contained in:
Amrit K Kandola
2020-10-06 19:28:48 +01:00
committed by GitHub Enterprise
parent a2940a4ba8
commit 678a62f152
1346 changed files with 125903 additions and 266970 deletions

View File

@@ -1,4 +0,0 @@
Please include the following information in your ticket.
- Version information for MQ, mq-golang, Go compiler
- A small code sample that demonstrates the issue.

View File

@@ -1,22 +0,0 @@
Please ensure all items are complete before opening.
- [ ] Tick to sign-off your agreement to the [IBM Contributor License Agreement](https://github.com/ibm-messaging/mq-golang/CLA.md)
- [ ] You have added tests for any code changes
- [ ] You have updated the [CHANGES.md](https://github.com/ibm-messaging/mq-golang/CHANGES.md)
- [ ] You have completed the PR template below:
## What
What was changed
## How
How the change was implemented or reasoning behind it
## Testing
How to test your changes work, not required for documentation changes.
## Issues
Links to the github issue(s) (if present) that this pull request is resolving.

View File

@@ -1,97 +0,0 @@
# Changelog
## May 2018
* Corrected package imports
* Formatted go code with `go fmt`
* Rearranged this file
* Removed logging from golang package `mqmetric`
* Moved samples to a separate repository
* Added build scripts for `ibmmq` and `mqmetric` packages and `ibmmq` samples
* Added unit tests for `ibmmq` and `mqmetric` packages
## March 2018 - v1.0.0
* Added V9.0.5 constant definitions
* Changed #cgo directives for Windows now the compiler supports standard path names
* Added mechanism to set MQ userid and password for Prometheus monitor
* Released v1.0.0 of this repository for use with golang dependency management tools
## October 2017
* Added V9.0.4 constant definitions - now generated from original MQ source code
* Added MQSC script to show how to redefine event queues for pub/sub
* Prometheus collector has new parameter to override the first component of the metric name
* Prometheus collector can now process channel-level statistics
## 18 May 2017
* Added the V9.0.3 constant definitions.
* Reinstated 64-bit structure "length" fields in cmqc.go after fixing a bug in the base product C source code generator.
## 25 Mar 2017
* Added the metaPrefix option to the Prometheus monitor. This allows selection of non-default resources such as the MQ Bridge for Salesforce included in MQ 9.0.2.
## 15 Feb 2017
* API BREAKING CHANGE: The MQI verbs have been changed to return a single error indicator instead of two separate values. See mqitest.go for examples of how MQRC/MQCC codes can now be tested and extracted. This change makes the MQI implementation a bit more natural for Go environments.
## 10 Jan 2017
* Added support for the MQCD and MQSCO structures to allow programmable client connectivity, without requiring a CCDT. See the clientconn sample program for an example of using the MQCD.
* Moved sample programs into subdirectory
## 14 Dec 2016
* Minor updates to this README for formatting
* Removed xxx_CURRENT_LENGTH definitions from cmqc
## 07 Nov 2016
* Added a collector that prints metrics in a simple JSON format. See the [README](cmd/mq_json/README.md) for more details.
* Fixed bug where freespace metrics were showing as non-integer bytes, not percentages
## 17 Oct 2016
* Added some Windows support. An example batch file is included in the mq_influx directory; changes would be needed to the MQSC script to call it. The other monitor programs can be supported with similar modifications.
* Added a "getting started" section to this README.
## 23 Aug 2016
* Added a collector for Amazon AWS CloudWatch monitoring. See the [README](cmd/mq_aws/README.md) for more details.
## 12 Aug 2016
* Added a OpenTSDB monitor. See the [README](cmd/mq_opentsdb/README.md) for more details.
* Added a Collectd monitor. See the [README](cmd/mq_coll/README.md) for more details.
* Added MQI MQCNO/MQCSP structures to support client connections and password authentication with MQCONNX.
* Allow client-mode connections from the monitor programs
* Added Grafana dashboards for the different monitors to show how to query them
* Changed database password mechanism so that "exec" maintains the PID for MQ services
## 04 Aug 2016
* Added a monitor command for exporting MQ data to InfluxDB. See the [README](cmd/mq_influx/README.md) for more details
* Restructured the monitoring code to put common material in the mqmetric package, called from the Influx and Prometheus monitors.
## 25 Jul 2016
* Added functions to handle basic PCF creation and parsing
* Added a monitor command for exporting MQ V9 queue manager data to Prometheus. See the [README](cmd/mq_prometheus/README.md) for more details
## 18 Jul 2016
* Changed structures so that most applications will not need to use cgo to imbed the MQ C headers
* Go programs will now use int32 where C programs use MQLONG
* Use of message handles, distribution lists require cgo for now
* Package ibmmq now includes the numeric #defines as a Go file, cmqc.go, for easier use
* Removed "src/" prefix from tree in github repo
* Removed need for buffer length parm on Put/Put1
* Updated comments
* Added MQINQ
* Added MQItoString function for some maps of values to constant names
## 08 Jul 2016
* Initial release

View File

@@ -1,32 +0,0 @@
IBM Contributor License Agreement
=================================
Version 1.0.0 January 14, 2014
In order for You (as defined below) to make intellectual property Contributions (as defined below) now or in the future to IBM GitHub repositories,
You must agree to this Contributor License Agreement ("CLA").
Please read this CLA carefully before accepting its terms. By accepting the CLA, You are agreeing to be bound by its terms.
If You submit a Pull Request against an IBM repository on GitHub You must include in the Pull Request a statement of Your acceptance of this CLA.
As used in this CLA:
(i) "You" (or "Your") shall mean the entity that is making this Agreement with IBM;
(ii)"Contribution" shall mean any original work of authorship, including any modifications or additions to an existing work, that is submitted by You to IBM for inclusion in,
or documentation of, any of the IBM GitHub repositories;
(iii) "Submit" (or "Submitted") means any form of communication sent to IBM (e.g. the content You post in a GitHub Issue or submit as part of a GitHub Pull Request).
This agreement applies to all Contributions You Submit.
This CLA, and the license(s) associated with the particular IBM GitHub repositories You are contributing to, provides a license to Your Contributions to IBM and downstream consumers,
but You still own Your Contributions, and except for the licenses provided for in this CLA, You reserve all right, title and interest in Your Contributions.
IBM requires that each Contribution You Submit now or in the future comply with the following four commitments.
1) You will only Submit Contributions where You have authored 100% of the content.
2) You will only Submit Contributions to which You have the necessary rights. This means that if You are employed You have received the necessary permissions from Your employer to make the
Contributions.
3) Whatever content You Contribute will be provided under the license(s) associated with the particular IBM GitHub repository You are contributing to.
4) You understand and agree that IBM GitHub repositories and Your contributions are public, and that a record of the contribution (including all personal information You submit with it)
is maintained indefinitely and may be redistributed consistent with the license(s) involved.
You will promptly notify the Eclipse Foundation if You become aware of any facts or circumstances that would make these commitments inaccurate in any way.
To do so, please create an Issue in the appropriate GitHub repository.

View File

@@ -1,49 +0,0 @@
# © Copyright IBM Corporation 2018
#
# 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
#
# 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.
ARG BASE_IMAGE=mq-sdk:9.0.5.0-x86_64-ubuntu-16.04
FROM $BASE_IMAGE
ENV GO_VERSION=1.10
# Install the Go compiler and Git
RUN export DEBIAN_FRONTEND=noninteractive \
&& bash -c 'source /etc/os-release; \
echo "deb http://archive.ubuntu.com/ubuntu/ ${UBUNTU_CODENAME} main restricted" > /etc/apt/sources.list; \
echo "deb http://archive.ubuntu.com/ubuntu/ ${UBUNTU_CODENAME}-updates main restricted" >> /etc/apt/sources.list; \
echo "deb http://archive.ubuntu.com/ubuntu/ ${UBUNTU_CODENAME}-backports main restricted universe" >> /etc/apt/sources.list;' \
&& apt-get update \
&& apt-get install -y --no-install-recommends golang-${GO_VERSION} git ca-certificates \
&& rm -rf /var/lib/apt/lists/*
ENV PATH="${PATH}:/usr/lib/go-${GO_VERSION}/bin:/go/bin" \
CGO_CFLAGS="-I/opt/mqm/inc/" \
CGO_LDFLAGS_ALLOW="-Wl,-rpath.*" \
GOPATH="/go" \
OUTPUT_DIR="${OUTPUT_DIR}"
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" "$GOPATH/pkg" \
&& chmod -R 777 "$GOPATH" \
&& mkdir -p "$GOPATH/src/github.com/ibm-messaging/mq-golang"
WORKDIR $GOPATH/src/github.com/ibm-messaging/mq-golang
COPY ./ibmmq ibmmq
COPY ./mqmetric mqmetric
RUN go build ./ibmmq \
&& go test ./ibmmq \
&& go build ./mqmetric \
&& go test ./mqmetric

View File

@@ -1,26 +0,0 @@
# © Copyright IBM Corporation 2018
#
# 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
#
# 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.
ARG BASE_IMAGE=mq-golang-build:9.0.5.0-x86_64-ubuntu-16.04
FROM $BASE_IMAGE
RUN mkdir -p "$GOPATH/src/github.com/ibm-messaging/mq-golang/samples"
WORKDIR $GOPATH/src/github.com/ibm-messaging/mq-golang/samples
COPY ./samples/clientconn clientconn
COPY ./samples/mqitest mqitest
RUN go install ./clientconn \
&& go install ./mqitest

View File

@@ -1,79 +0,0 @@
# © Copyright IBM Corporation 2018
#
# 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
#
# 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.
###############################################################################
# Conditional variables - you can override the values of these variables from
# the command line
###############################################################################
# BASE_IMAGE is the MQ SDK base image to use
BASE_IMAGE ?= mq-sdk:9.0.5.0-x86_64-ubuntu-16.04
# GO_IMAGE is the GOLANG image to use for building samples
GO_IMAGE ?= golang:1.10
# DOCKER is the Docker command to run
DOCKER ?= docker
# BUILD_IMAGE is the name of the image that will be produced while building packages
BUILD_IMAGE ?= mq-golang-build:9.0.5.0-x86_64-ubuntu-16.04
# SAMPLE_BUILD_IMAGE is the name of the image that will be produced while building samples
SAMPLE_BUILD_IMAGE ?= mq-sample-build:9.0.5.0-x86_64-ubuntu-16.04
###############################################################################
# Other variables
###############################################################################
ifneq (,$(findstring Microsoft,$(shell uname -r)))
PLATFORM=WINDOWS
else
PLATFORM=UNIX
endif
###############################################################################
# Build targets
###############################################################################
# Build all packages when on unix
.PHONY: all
ifeq ("$(PLATFORM)", "WINDOWS")
all: unsupported-message
else
all: build-packages-unix build-samples-unix
endif
.PHONY: clean
clean:
$(DOCKER) rmi -f $(BUILD_IMAGE)
$(DOCKER) rmi -f $(SAMPLE_BUILD_IMAGE)
.PHONY: build-packages-unix
build-packages-unix:
$(info $(SPACER)$(shell printf $(TITLE)"Building packages in build container"$(END)))
$(call docker-build,$(BUILD_IMAGE),Dockerfile-build-packages,$(BASE_IMAGE))
.PHONY: build-samples-unix
build-samples-unix: build-packages-unix
$(info $(SPACER)$(shell printf $(TITLE)"Building samples in build container"$(END)))
$(call docker-build,$(SAMPLE_BUILD_IMAGE),Dockerfile-build-samples,$(BUILD_IMAGE))
.PHONY: unsupported-message
unsupported-message:
$(info $(SPACER)$(shell printf $(TITLE)"This makefile can only be ran on UNIX platforms"$(END)))
define docker-build
# Build the image first to compile the package/samples
$(DOCKER) build -t $1 \
-f $2 \
--build-arg BASE_IMAGE=$3 \
.
endef
include formatting.mk

View File

@@ -1,117 +0,0 @@
# mq-golang
This repository demonstrates how you can call IBM MQ from applications written in the Go language.
> **NOTICE**: Please ensure that you use a dependency management tool such as [dep](https://github.com/golang/dep) or [Glide](http://glide.sh/), and add a specific version dependency. The current content has been marked as version 1.0.0, and a new version with breaking changes will be released soon. By using a dependency manager, you can continue to use the old version if you want to.
This repository previously contained sample programs that exported MQ statistics to some monitoring packages. These have now been moved to a new [GitHub repository called mq-metric-samples](https://github.com/ibm-messaging/mq-metric-samples).
A minimum level of MQ V9 is required to build these packages.
The monitoring data published by the queue manager is not available before that version; the interface also assumes availability of MQI structures from that level of MQ.
## Health Warning
This package is provided as-is with no guarantees of support or updates. There are also no guarantees of compatibility with any future versions of the package; the API is subject to change based on any feedback.
## MQI Description
The ibmmq directory contains a Go package, exposing an MQI-like interface.
The intention is to give an API that is more natural for Go programmers than the common procedural MQI. For example, fixed length string arrays from the C API such as MQCHAR48 are represented by the native Go string type. Conversion between these types is handled within the ibmmq package itself, removing the need for Go programmers to know about it.
A short program in the mqitest directory gives an example of using this interface, to put and get messages and to subscribe to a topic.
Feedback on the utility of this package, thoughts about whether it should be changed or extended are welcomed.
## Using the package
To use code in this repository, you will need to be able to build Go applications, and have a copy of MQ installed to build against. It uses cgo to access the MQI C structures and definitions. It assumes that MQ has been installed in the default location on a Linux platform (`/opt/mqm`) but you can easily change the cgo directives in the source files if necessary.
Some Windows capability is also included. This has been tested with Go 1.10 compiler, which now permits standard Windows paths (eg including spaces) so the CGO directives can point at the normal MQ install path.
## Getting started
If you are unfamiliar with Go, the following steps can help create a working environment with source code in a suitable tree. Initial setup tends to be platform-specific, but subsequent steps are independent of the platform.
### Linux
* Install the Go runtime and compiler. On Linux, the packaging may vary but a typical directory for the code is `/usr/lib/golang`.
* Create a working directory. For example, ```mkdir $HOME/gowork```
* Set environment variables. Based on the previous lines,
```export GOROOT=/usr/lib/golang```
```export GOPATH=$HOME/gowork```
* If using a version of Go from after 2017, you must set environment variables to permit some compile/link flags. This is due to a security fix in the compiler.
```export CGO_LDFLAGS_ALLOW="-Wl,-rpath.*"```
* Install the git client
### Windows
* Install the Go runtime and compiler. On Windows, the common directory is `c:\Go`
* Ensure you have a gcc-based compiler, for example from the Cygwin distribution. I use the mingw variation, to ensure compiled code can be used on systems without Cygwin installed
* Create a working directory. For example, ```mkdir c:\Gowork```
* Set environment variables. Based on the previous lines,
```set GOROOT=c:\Go```
```set GOPATH=c:\Gowork```
```set CC=x86_64-w64-mingw32-gcc.exe```
* The `CGO_LDFLAGS_ALLOW` variable is not needed on Windows
* Install the git client
* Make sure the MQ include files and libraries are in a path that does not include spaces or other special characters, as discussed above.
### Common
* Make sure your PATH includes routes to the Go compiler (`$GOROOT/bin`), the Git client, and the C compiler.
* Change directory to the workspace you created earlier. (`cd $GOPATH`)
* Use git to get a copy of the MQ components into a new directory in the workspace.
```git clone https://github.com/ibm-messaging/mq-golang.git src/github.com/ibm-messaging/mq-golang```
* Compile the `ibmmq` component:
```go install ./src/github.com/ibm-messaging/mq-golang/ibmmq```
* Compile the `mqmetric` component:
```go install ./src/github.com/ibm-messaging/mq-golang/mqmetric```
* Follow the instructions in the [mq-metric-samples repository](https://github.com/ibm-messaging/mq-metric-samples) to compile the sample programs you are interested in.
At this point, you should have a compiled copy of the code in `$GOPATH/bin`.
## Limitations
Not all of the MQI verbs are available through the `ibmmq` package. This
implementation concentrates on the core API calls needed to put and get messages.
Currently unavailable verbs include:
* MQSET
* All of the message property manipulators
* MQCB
There are also no structure handlers for message headers such as MQRFH2 or MQDLH.
## History
See [CHANGELOG](CHANGELOG.md) in this directory.
## Issues and Contributions
For feedback and issues relating specifically to this package, please use the [GitHub issue tracker](https://github.com/ibm-messaging/mq-golang/issues).
Contributions to this package can be accepted under the terms of the IBM Contributor License Agreement,
found in the [CLA file](CLA.md) of this repository. When submitting a pull request, you must include a statement stating
you accept the terms in the CLA.
## Copyright
© Copyright IBM Corporation 2016, 2018

View File

@@ -1,17 +0,0 @@
GREEN="\033[32m"
RED="\033[31m"
BLUE="\033[34m"
PURPLE="\033[35m"
AQUA="\033[36m"
END="\033[0m"
UNDERLINE="\033[4m"
BOLD="\033[1m"
TITLE=$(BLUE)$(BOLD)$(UNDERLINE)
define SPACER
endef

0
vendor/github.com/ibm-messaging/mq-golang/ibmmq/cmqc_windows.go generated vendored Executable file → Normal file
View File

View File

@@ -1,291 +0,0 @@
/*
© Copyright IBM Corporation 2018
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
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 ibmmq
import (
"testing"
)
// Tests for mqistr.go
func TestMqstrerror(t *testing.T) {
output := mqstrerror("test", 0, 0)
expected := "test: MQCC = MQCC_OK [0] MQRC = MQRC_NONE [0]"
if output != expected {
t.Logf("Gave 0, 0. Expected: %s, Got: %s", expected, output)
t.Fail()
}
output = mqstrerror("test", 1, 2393)
expected = "test: MQCC = MQCC_WARNING [1] MQRC = MQRC_SSL_INITIALIZATION_ERROR [2393]"
if output != expected {
t.Logf("Gave 1, 2393. Expected: %s, Got: %s", expected, output)
t.Fail()
}
output = mqstrerror("test", 2, 2035)
expected = "test: MQCC = MQCC_FAILED [2] MQRC = MQRC_NOT_AUTHORIZED [2035]"
if output != expected {
t.Logf("Gave 2, 2035. Expected: %s, Got: %s", expected, output)
t.Fail()
}
}
func TestMQItoString(t *testing.T) {
output := MQItoString("BACF", 7019)
expected := "MQBACF_ALTERNATE_SECURITYID"
if output != expected {
t.Logf("Gave BACF, 7019. Expected: %s, Got: %s", expected, output)
t.Fail()
}
output = MQItoString("CA", 2030)
expected = "MQCA_CLUSTER_NAMELIST"
if output != expected {
t.Logf("Gave CA, 2030. Expected: %s, Got: %s", expected, output)
t.Fail()
}
output = MQItoString("CA", 3134)
expected = "MQCACF_ACTIVITY_DESC"
if output != expected {
t.Logf("Gave CA, 3134. Expected: %s, Got: %s", expected, output)
t.Fail()
}
output = MQItoString("CA", 3529)
expected = "MQCACH_CHANNEL_START_DATE"
if output != expected {
t.Logf("Gave CA, 3529. Expected: %s, Got: %s", expected, output)
t.Fail()
}
output = MQItoString("CA", 2708)
expected = "MQCAMO_END_TIME"
if output != expected {
t.Logf("Gave CA, 2708. Expected: %s, Got: %s", expected, output)
t.Fail()
}
output = MQItoString("CC", -1)
expected = "MQCC_UNKNOWN"
if output != expected {
t.Logf("Gave CC, -1. Expected: %s, Got: %s", expected, output)
t.Fail()
}
output = MQItoString("CMD", 208)
expected = "MQCMD_CHANGE_PROT_POLICY"
if output != expected {
t.Logf("Gave CMD, 208. Expected: %s, Got: %s", expected, output)
t.Fail()
}
output = MQItoString("IA", 102)
expected = "MQIA_ADOPTNEWMCA_CHECK"
if output != expected {
t.Logf("Gave IA, 102. Expected: %s, Got: %s", expected, output)
t.Fail()
}
output = MQItoString("IA", 1019)
expected = "MQIACF_AUTH_INFO_ATTRS"
if output != expected {
t.Logf("Gave IA, 1019. Expected: %s, Got: %s", expected, output)
t.Fail()
}
output = MQItoString("IA", 1584)
expected = "MQIACH_ADAPS_MAX"
if output != expected {
t.Logf("Gave IA, 1584. Expected: %s, Got: %s", expected, output)
t.Fail()
}
output = MQItoString("IA", 770)
expected = "MQIAMO_CBS_FAILED"
if output != expected {
t.Logf("Gave IA, 770. Expected: %s, Got: %s", expected, output)
t.Fail()
}
output = MQItoString("IA", 745)
expected = "MQIAMO64_BROWSE_BYTES"
if output != expected {
t.Logf("Gave IA, 745. Expected: %s, Got: %s", expected, output)
t.Fail()
}
output = MQItoString("OT", 1008)
expected = "MQOT_SERVER_CHANNEL"
if output != expected {
t.Logf("Gave OT, 1008. Expected: %s, Got: %s", expected, output)
t.Fail()
}
output = MQItoString("RC", 2277)
expected = "MQRC_CD_ERROR"
if output != expected {
t.Logf("Gave RC, 2277. Expected: %s, Got: %s", expected, output)
t.Fail()
}
output = MQItoString("RC", 3049)
expected = "MQRCCF_CCSID_ERROR"
if output != expected {
t.Logf("Gave RC, 3049. Expected: %s, Got: %s", expected, output)
t.Fail()
}
output = MQItoString("BADVALUE", 0)
expected = ""
if output != expected {
t.Logf("Gave BADVALUE, 0. Expected: %s, Got: %s", expected, output)
t.Fail()
}
output = MQItoString("IA", 0123123123123)
expected = ""
if output != expected {
t.Logf("Gave IA, 0123123123123. Expected: %s, Got: %s", expected, output)
t.Fail()
}
}
// Tests for mqiPCF.go
func TestReadPCFHeader(t *testing.T) {
testHeader := NewMQCFH()
returned, offset := ReadPCFHeader(testHeader.Bytes())
if returned.Type != testHeader.Type {
t.Logf("Returned 'Type' does not match Initial: Expected: %d Got: %d", testHeader.Type, returned.Type)
t.Fail()
}
if returned.StrucLength != testHeader.StrucLength {
t.Logf("Returned 'StrucLength' does not match Initial: Expected: %d Got: %d", testHeader.StrucLength, returned.StrucLength)
t.Fail()
}
if returned.Version != testHeader.Version {
t.Logf("Returned 'Version' does not match Initial: Expected: %d Got: %d", testHeader.Version, returned.Version)
t.Fail()
}
if returned.Command != testHeader.Command {
t.Logf("Returned 'Command' does not match Initial: Expected: %d Got: %d", testHeader.Command, returned.Command)
t.Fail()
}
if returned.MsgSeqNumber != testHeader.MsgSeqNumber {
t.Logf("Returned 'MsgSeqNumber' does not match Initial: Expected: %d Got: %d", testHeader.MsgSeqNumber, returned.MsgSeqNumber)
t.Fail()
}
if returned.Control != testHeader.Control {
t.Logf("Returned 'Control' does not match Initial: Expected: %d Got: %d", testHeader.Control, returned.Control)
t.Fail()
}
if returned.CompCode != testHeader.CompCode {
t.Logf("Returned 'CompCode' does not match Initial: Expected: %d Got: %d", testHeader.CompCode, returned.CompCode)
t.Fail()
}
if returned.Reason != testHeader.Reason {
t.Logf("Returned 'Reason' does not match Initial: Expected: %d Got: %d", testHeader.Reason, returned.Reason)
t.Fail()
}
if returned.ParameterCount != testHeader.ParameterCount {
t.Logf("Returned 'ParameterCount' does not match Initial: Expected: %d Got: %d", testHeader.ParameterCount, returned.ParameterCount)
t.Fail()
}
if offset != 36 {
t.Logf("Expected offset to be 36 but was %d", offset)
t.Fail()
}
}
func TestReadPCFParameter(t *testing.T) {
start := PCFParameter{
Parameter: MQCACF_APPL_NAME,
Int64Value: []int64{100},
String: []string{"HELLOTEST"},
ParameterCount: 1,
}
t.Log("-MQCFT_INTEGER-")
start.Type = MQCFT_INTEGER
back, _ := ReadPCFParameter(start.Bytes())
verifyParam(t, &start, back)
t.Log("-MQCFT_STRING-")
start.Type = MQCFT_STRING
back, _ = ReadPCFParameter(start.Bytes())
verifyParam(t, &start, back)
// The rest of the types are not implemented in the Bytes()
// function so cannot be tested.
}
func verifyParam(t *testing.T, given, returned *PCFParameter) {
t.Log("Testing Type")
if given.Type != returned.Type {
t.Logf("Returned 'Type' does not match Initial: Expected: %d Got: %d", given.Type, returned.Type)
t.Fail()
}
t.Log("Testing Parameter")
if given.Parameter != returned.Parameter {
t.Logf("Returned 'Parameter' does not match Initial: Expected: %d Got: %d", given.Parameter, returned.Parameter)
t.Fail()
}
if given.Type == MQCFT_INTEGER || given.Type == MQCFT_INTEGER64 || given.Type == MQCFT_INTEGER_LIST || given.Type == MQCFT_INTEGER64_LIST {
t.Log("Testing Length")
if len(given.Int64Value) != len(returned.Int64Value) {
t.Logf("Length of Returned 'Int64Value' does not match Initial: Expected: %d Got: %d", len(given.Int64Value), len(returned.Int64Value))
t.Fail()
} else if given.Int64Value[0] != returned.Int64Value[0] {
t.Logf("Returned parameter 'Int64Value' did not match. Expected: %d, Got: %d", given.Int64Value[0], returned.Int64Value[0])
t.Fail()
}
}
if given.Type == MQCFT_STRING || given.Type == MQCFT_STRING_LIST {
if len(given.String) != len(returned.String) {
t.Logf("Length of Returned 'String' does not match Initial: Expected: %d Got: %d", len(given.String), len(returned.String))
t.Fail()
} else if given.String[0] != returned.String[0] {
t.Logf("Returned parameter 'String' did not match. Expected: %s, Got: %s", given.String[0], returned.String[0])
t.Fail()
}
}
if given.Type == MQCFT_GROUP {
if given.ParameterCount != returned.ParameterCount {
t.Logf("Returned 'ParameterCount' does not match Initial: Expected: %d Got: %d", given.ParameterCount, returned.ParameterCount)
t.Fail()
}
}
if len(given.GroupList) != len(returned.GroupList) {
t.Logf("Length of Returned 'GroupList' does not match Initial: Expected: %d Got: %d", len(given.GroupList), len(returned.GroupList))
t.Fail()
} // Should be nil
}
func TestRoundTo4(t *testing.T) {
start := []int32{12, 13, 14, 15, 16, 17}
expected := []int32{12, 16, 16, 16, 16, 20}
for i, e := range start {
back := roundTo4(e)
if back != expected[i] {
t.Logf("Passed: %d. Expected: %d. Got: %d", e, expected[i], back)
t.Fail()
}
}
}

0
vendor/github.com/ibm-messaging/mq-golang/ibmmq/mqistr.go generated vendored Executable file → Normal file
View File

0
vendor/github.com/ibm-messaging/mq-golang/mqmetric/discover.go generated vendored Executable file → Normal file
View File

View File

@@ -1,286 +0,0 @@
/*
© Copyright IBM Corporation 2018
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
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 mqmetric
import (
"fmt"
"io/ioutil"
"os"
"testing"
"github.com/ibm-messaging/mq-golang/ibmmq"
)
func TestNormalise(t *testing.T) {
testCases := []struct {
dataType int32
dataTypeName string
value int64
expected float64
}{
{ibmmq.MQIAMO_MONITOR_PERCENT, "MQIAMO_MONITOR_PERCENT", 1, 0.01},
{ibmmq.MQIAMO_MONITOR_PERCENT, "MQIAMO_MONITOR_PERCENT", 1000000, 10000},
{ibmmq.MQIAMO_MONITOR_HUNDREDTHS, "MQIAMO_MONITOR_HUNDREDTHS", 1, 0.01},
{ibmmq.MQIAMO_MONITOR_HUNDREDTHS, "MQIAMO_MONITOR_HUNDREDTHS", 1000000, 10000},
{ibmmq.MQIAMO_MONITOR_MB, "MQIAMO_MONITOR_MB", 1000000, 1048576000000},
{ibmmq.MQIAMO_MONITOR_GB, "MQIAMO_MONITOR_GB", 1000000, 1073741824000000},
{ibmmq.MQIAMO_MONITOR_MICROSEC, "MQIAMO_MONITOR_MICROSEC", 1000000, 1},
{ibmmq.MQIAMO_MONITOR_MICROSEC, "MQIAMO_MONITOR_MICROSEC", 1, 0.000001},
}
for _, tc := range testCases {
t.Run(fmt.Sprintf("%s/%d", tc.dataTypeName, tc.value), func(t *testing.T) {
test := MonElement{Datatype: tc.dataType}
returned := Normalise(&test, "", tc.value)
if returned != tc.expected {
t.Logf("Gave %s, %d. Expected: %f, Got: %f", tc.dataTypeName, tc.value, tc.expected, returned)
t.Fail()
}
})
}
}
func TestReadPatterns(t *testing.T) {
const filename = "testFile"
testCases := []struct {
name string
value string
expected string
}{
{"golden", "test1=yes\ntest2=no\n", "test1=yes,test2=no"},
{"nolf", "test1=yes\ntest2=no", "test1=yes,test2=no"},
{"crlf", "test1=yes\r\ntest2=no\r\n", "test1=yes,test2=no"},
{"oneliner", "test1=yes,test2=no\ntest3=maybe", "test1=yes,test2=no,test3=maybe"},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
//Create dummy test file
err := ioutil.WriteFile(filename, []byte(tc.value), 0644)
if err != nil {
t.Fatalf("Could not create test file - %v", err)
}
defer os.Remove(filename)
returned, err := ReadPatterns(filename)
if err != nil {
t.Logf("Got error while running ReadPatterns - %v", err)
t.Fail()
} else if returned != tc.expected {
t.Logf("File was not parsed correctly. Expected: %s. Got: %s", tc.expected, returned)
t.Fail()
}
})
}
}
func TestFormatDescription(t *testing.T) {
testCases := []struct {
value string
expected string
}{
{"hello", "hello_count"},
{"no space", "no_space_count"},
{"no/slash", "no_slash_count"},
{"no-dash", "no_dash_count"},
{"single___underscore", "single_underscore_count"},
{"single__underscore__multiplace", "single_underscore_multiplace_count"},
{"ALLLOWER", "alllower_count"},
{"this_bytes_written_switch", "this_written_switch_count"},
{"this_byte_max_switch", "this_max_switch_count"},
{"this_seconds_in_use_switch", "this_in_use_switch_count"},
{"this messages_expired_switch", "this_expired_messages_switch_count"},
{"this_seconds_max_switch", "this_max_switch_count"},
{"this_count_max_switch", "this_max_switch_count"},
{"this_percentage_max_switch", "this_max_switch_count"},
}
for _, tc := range testCases {
t.Run(tc.value, func(t *testing.T) {
elem := MonElement{
Description: tc.value,
}
returned := formatDescription(&elem)
if returned != tc.expected {
t.Logf("Gave %s. Expected: %s, Got: %s", tc.value, tc.expected, returned)
t.Fail()
}
})
}
}
func TestSuffixes(t *testing.T) {
baseDescription := "test_suffix"
testCases := []struct {
name string
value int32
expected string
}{
{"MQIAMO_MONITOR_MB", ibmmq.MQIAMO_MONITOR_MB, baseDescription + "_bytes"},
{"MQIAMO_MONITOR_GB", ibmmq.MQIAMO_MONITOR_GB, baseDescription + "_bytes"},
{"MQIAMO_MONITOR_MICROSEC", ibmmq.MQIAMO_MONITOR_MICROSEC, baseDescription + "_seconds"},
{"MQIAMO_MONITOR_PERCENT", ibmmq.MQIAMO_MONITOR_PERCENT, baseDescription + "_percentage"},
{"MQIAMO_MONITOR_HUNDREDTHS", ibmmq.MQIAMO_MONITOR_HUNDREDTHS, baseDescription + "_percentage"},
{"0", 0, baseDescription + "_count"},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
elem := MonElement{
Description: baseDescription,
Datatype: tc.value,
}
returned := formatDescription(&elem)
if returned != tc.expected {
t.Logf("Gave %s/%d Expected: %s, Got: %s", baseDescription, tc.value, tc.expected, returned)
t.Fail()
}
})
}
// special case log_bytes
t.Run("log_bytes", func(t *testing.T) {
elem := MonElement{
Description: "log_test_suffix",
Datatype: 0,
}
returned := formatDescription(&elem)
if returned != "log_test_suffix_bytes" {
t.Logf("Gave log_test_suffix/0 Expected: %s, Got: %s", "log_test_suffix_bytes", returned)
t.Fail()
}
})
// special case log_total
t.Run("log_bytes", func(t *testing.T) {
elem := MonElement{
Description: "log_total_suffix",
Datatype: 0,
}
returned := formatDescription(&elem)
if returned != "log_suffix_total" {
t.Logf("Gave log_total_suffix/0 Expected: %s, Got: %s", "log_suffix_total", returned)
t.Fail()
}
})
}
func TestParsePCFResponse(t *testing.T) {
testCases := []struct {
name string
params []ibmmq.PCFParameter
}{
{
"noParams",
make([]ibmmq.PCFParameter, 0),
},
{
"oneParam",
[]ibmmq.PCFParameter{
ibmmq.PCFParameter{
Type: ibmmq.MQCFT_STRING, // String
Parameter: ibmmq.MQCACF_APPL_NAME,
String: []string{"HELLOTEST"},
ParameterCount: 1,
},
},
},
{
"twoParams",
[]ibmmq.PCFParameter{
ibmmq.PCFParameter{
Type: ibmmq.MQCFT_STRING, // String
Parameter: ibmmq.MQCACF_APPL_NAME,
String: []string{"HELLOTEST"},
ParameterCount: 1,
},
ibmmq.PCFParameter{
Type: ibmmq.MQCFT_STRING, // String
Parameter: ibmmq.MQCACF_APPL_NAME,
String: []string{"FIRST"},
ParameterCount: 1,
},
},
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
cfh := ibmmq.NewMQCFH()
cfh.Type = ibmmq.MQCFT_RESPONSE
cfh.ParameterCount = int32(len(tc.params))
headerbytes := cfh.Bytes()
parmbytes := []byte{}
for _, parm := range tc.params {
parmbytes = append(parmbytes, parm.Bytes()...)
}
messagebytes := append(headerbytes, parmbytes...)
returned, last := parsePCFResponse(messagebytes)
if len(returned) != len(tc.params) && !last {
t.Logf("Gave header and parameter. Expected: 1, false , Got: %d, %t", len(returned), last)
t.Fail()
} else {
for i := range returned {
t.Logf("Checking param %d", i)
checkParamsMatch(returned[i], &tc.params[i], t)
}
}
})
}
}
func checkParamsMatch(returned *ibmmq.PCFParameter, expected *ibmmq.PCFParameter, t *testing.T) {
if returned.Type != expected.Type {
t.Logf("Returned parameter 'Type' did not match. Expected: %d, Got: %d", expected.Type, returned.Type)
t.Fail()
}
if returned.Parameter != expected.Parameter {
t.Logf("Returned parameter 'Parameter' did not match. Expected: %d, Got: %d", expected.Parameter, returned.Parameter)
t.Fail()
}
if len(returned.String) != len(expected.String) {
t.Logf("Length of Returned parameter 'String' did not match. Expected: %d, Got: %d", len(expected.String), len(returned.String))
t.Fail()
} else {
for i := range returned.String {
if returned.String[i] != expected.String[i] {
t.Logf("Returned parameter 'String[%d]' did not match. Expected: %s, Got: %s", i, expected.String[i], returned.String[i])
t.Fail()
}
}
}
if len(returned.Int64Value) != len(expected.Int64Value) {
t.Logf("Length of Returned parameter 'Int64Value' did not match. Expected: %d, Got: %d", len(expected.Int64Value), len(returned.Int64Value))
t.Fail()
} else {
for i := range returned.Int64Value {
if returned.Int64Value[i] != expected.Int64Value[i] {
t.Logf("Returned parameter 'Int64Value[%d]' did not match. Expected: %d, Got: %d", i, expected.Int64Value[i], returned.Int64Value[i])
t.Fail()
}
}
}
if len(returned.GroupList) != len(expected.GroupList) {
t.Logf("Length of Returned parameter 'GroupList' did not match. Expected: %d, Got: %d", len(expected.GroupList), len(returned.GroupList))
t.Fail()
} else {
for i := range returned.GroupList {
checkParamsMatch(returned.GroupList[i], expected.GroupList[i], t)
}
}
}

View File

@@ -1,118 +0,0 @@
/*
This is a short sample to show how to connect to a remote
queue manager in a Go program without requiring external
client configuration such as a CCDT. Only the basic
parameters are needed here - channel name and connection information -
along with the queue manager name.
For example, run as
clientconn QMGR1 "SYSTEM.DEF.SVRCONN" "myhost.example.com(1414)"
If the MQSAMP_USER_ID environment variable is set, then a userid/password
flow is also made to authenticate to the queue manager.
There is no attempt in this sample to configure advanced security features
such TLS.
If an error occurs, the error is reported.
*/
package main
/*
Copyright (c) IBM Corporation 2017
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
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
Contributors:
Mark Taylor - Initial Contribution
*/
import (
"bufio"
"fmt"
"os"
"time"
"github.com/ibm-messaging/mq-golang/ibmmq"
)
func main() {
var qMgrName string
var err error
var qMgr ibmmq.MQQueueManager
var rc int
if len(os.Args) != 4 {
fmt.Println("clientconn <qmgrname> <channelname> <conname>")
fmt.Println("")
fmt.Println("For example")
fmt.Println(" clientconn QMGR1 \"SYSTEM.DEF.SVRCONN\" \"myhost.example.com(1414)\"")
fmt.Println("All parameters are required.")
os.Exit(1)
}
// Which queue manager do we want to connect to
qMgrName = os.Args[1]
// Allocate the MQCNO and MQCD structures needed for the
// MQCONNX call.
cno := ibmmq.NewMQCNO()
cd := ibmmq.NewMQCD()
// Fill in the required fields in the
// MQCD channel definition structure
cd.ChannelName = os.Args[2]
cd.ConnectionName = os.Args[3]
// Reference the CD structure from the CNO
// and indicate that we want to use the client
// connection method.
cno.ClientConn = cd
cno.Options = ibmmq.MQCNO_CLIENT_BINDING
// Also fill in the userid and password if the MQSAMP_USER_ID
// environment variable is set. This is the same as the C
// sample programs such as amqsput.
userId := os.Getenv("MQSAMP_USER_ID")
if userId != "" {
scanner := bufio.NewScanner(os.Stdin)
csp := ibmmq.NewMQCSP()
csp.AuthenticationType = ibmmq.MQCSP_AUTH_USER_ID_AND_PWD
csp.UserId = userId
fmt.Printf("Enter password for qmgr %s: \n", qMgrName)
scanner.Scan()
csp.Password = scanner.Text()
// And make the CNO refer to the CSP structure
cno.SecurityParms = csp
}
// And connect. Wait a short time before
// disconnecting.
qMgr, err = ibmmq.Connx(qMgrName, cno)
if err == nil {
fmt.Printf("Connection to %s succeeded.\n", qMgrName)
d, _ := time.ParseDuration("5s")
time.Sleep(d)
qMgr.Disc()
rc = 0
} else {
fmt.Printf("Connection to %s failed.\n", qMgrName)
fmt.Println(err)
rc = int(err.(*ibmmq.MQReturn).MQCC)
}
fmt.Println("Done.")
os.Exit(rc)
}

View File

@@ -1,275 +0,0 @@
/*
This is a short sample to show how to call IBM MQ from
a Go program.
The flow is to connect to a queue manager,
open the queue named on the command line,
put a message and then get it back.
The queue is closed.
The program then subscribes to the topic corresponding
to collecting activity trace for itself - this requires MQ V9.
Finally, it closes the subscription and target queue, and
disconnects.
If an error occurs at any stage, the error is reported and
subsequent steps skipped.
*/
package main
/*
Copyright (c) IBM Corporation 2016
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
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
Contributors:
Mark Taylor - Initial Contribution
*/
import (
"fmt"
"os"
"strings"
"github.com/ibm-messaging/mq-golang/ibmmq"
)
func main() {
var openOptions int32
var qMgrObject ibmmq.MQObject
var qObject ibmmq.MQObject
var managedQObject ibmmq.MQObject
var subObject ibmmq.MQObject
var qMgrName string
if len(os.Args) != 3 {
fmt.Println("mqitest <qname> <qmgrname>")
fmt.Println(" Both parms required")
os.Exit(1)
}
qMgrName = os.Args[2]
connected := false
qMgr, err := ibmmq.Conn(qMgrName)
if err != nil {
fmt.Println(err)
} else {
connected = true
fmt.Println("Connected to queue manager ", qMgrName)
}
// MQOPEN of the queue named on command line
if err == nil {
mqod := ibmmq.NewMQOD()
openOptions = ibmmq.MQOO_OUTPUT + ibmmq.MQOO_FAIL_IF_QUIESCING
openOptions |= ibmmq.MQOO_INPUT_AS_Q_DEF
mqod.ObjectType = ibmmq.MQOT_Q
mqod.ObjectName = os.Args[1]
qObject, err = qMgr.Open(mqod, openOptions)
if err != nil {
fmt.Println(err)
} else {
fmt.Println("Opened queue", qObject.Name)
}
}
// MQPUT a message
// Create the standard MQI structures MQMD, MQPMO and
// set the values.
// The message is always sent as bytes, so has to be converted
// before the MQPUT.
if err == nil {
putmqmd := ibmmq.NewMQMD()
pmo := ibmmq.NewMQPMO()
pmo.Options = ibmmq.MQPMO_SYNCPOINT | ibmmq.MQPMO_NEW_MSG_ID | ibmmq.MQPMO_NEW_CORREL_ID
putmqmd.Format = "MQSTR"
msgData := "Hello from Go"
buffer := []byte(msgData)
err = qObject.Put(putmqmd, pmo, buffer)
if err != nil {
fmt.Println(err)
} else {
fmt.Println("Put message to", qObject.Name)
}
}
// The message was put in syncpoint so it needs
// to be committed.
if err == nil {
err = qMgr.Cmit()
if err != nil {
fmt.Println(err)
}
}
// MQGET all messages on the queue. Wait 3 seconds for any more
// to arrive.
if err == nil {
msgAvail := true
for msgAvail == true {
var datalen int
getmqmd := ibmmq.NewMQMD()
gmo := ibmmq.NewMQGMO()
gmo.Options = ibmmq.MQGMO_NO_SYNCPOINT | ibmmq.MQGMO_FAIL_IF_QUIESCING
gmo.Options |= ibmmq.MQGMO_WAIT
gmo.WaitInterval = 3000
buffer := make([]byte, 32768)
datalen, err = qObject.Get(getmqmd, gmo, buffer)
if err != nil {
msgAvail = false
fmt.Println(err)
mqret := err.(*ibmmq.MQReturn)
if mqret.MQRC == ibmmq.MQRC_NO_MSG_AVAILABLE {
// not a real error so reset err
err = nil
}
} else {
fmt.Printf("Got message of length %d: ", datalen)
fmt.Println(strings.TrimSpace(string(buffer[:datalen])))
}
}
}
// MQCLOSE the queue
if err == nil {
err = qObject.Close(0)
if err != nil {
fmt.Println(err)
} else {
fmt.Println("Closed queue")
}
}
// This section demonstrates subscribing to a topic
// where the topic string is set to collect activity trace
// from this program - it needs MQ V9 for publications to
// automatically be generated on this topic.
if err == nil {
mqsd := ibmmq.NewMQSD()
mqsd.Options = ibmmq.MQSO_CREATE
mqsd.Options |= ibmmq.MQSO_NON_DURABLE
mqsd.Options |= ibmmq.MQSO_FAIL_IF_QUIESCING
mqsd.Options |= ibmmq.MQSO_MANAGED
mqsd.ObjectString = "$SYS/MQ/INFO/QMGR/" + qMgrName + "/ActivityTrace/ApplName/mqitest"
subObject, err = qMgr.Sub(mqsd, &managedQObject)
if err != nil {
fmt.Println(err)
} else {
fmt.Println("Subscribed to topic ", mqsd.ObjectString)
}
}
// Loop on the managed queue created by the MQSUB call until there
// are no more messages. Because these are going to be PCF-format
// events, they cannot be simply printed so here I'm just
// printing the format of the message to show that something has
// been retrieved.
if err == nil {
msgAvail := true
for msgAvail == true {
var datalen int
getmqmd := ibmmq.NewMQMD()
gmo := ibmmq.NewMQGMO()
gmo.Options = ibmmq.MQGMO_NO_SYNCPOINT | ibmmq.MQGMO_FAIL_IF_QUIESCING
gmo.Options |= ibmmq.MQGMO_WAIT
gmo.WaitInterval = 3000
buffer := make([]byte, 32768)
datalen, err = managedQObject.Get(getmqmd, gmo, buffer)
if err != nil {
msgAvail = false
fmt.Println(err)
mqret := err.(*ibmmq.MQReturn)
if mqret.MQRC == ibmmq.MQRC_NO_MSG_AVAILABLE {
// not a real error so reset err, but
// end retrieval loop
err = nil
}
} else {
fmt.Printf("Got message of length %d. Format = %s\n", datalen, getmqmd.Format)
}
}
}
// MQCLOSE the subscription, ignoring errors.
if err == nil {
subObject.Close(0)
}
if err == nil {
mqod := ibmmq.NewMQOD()
openOptions = ibmmq.MQOO_INQUIRE + ibmmq.MQOO_FAIL_IF_QUIESCING
mqod.ObjectType = ibmmq.MQOT_Q_MGR
mqod.ObjectName = ""
qMgrObject, err = qMgr.Open(mqod, openOptions)
if err != nil {
fmt.Println(err)
} else {
fmt.Printf("Opened QMgr for MQINQ\n")
}
}
if err == nil {
selectors := []int32{ibmmq.MQCA_Q_MGR_NAME,
ibmmq.MQCA_DEAD_LETTER_Q_NAME,
ibmmq.MQIA_MSG_MARK_BROWSE_INTERVAL}
intAttrs, charAttrs, err := qMgrObject.Inq(selectors, 2, 160)
if err != nil {
fmt.Println(err)
} else {
returnedName := string(charAttrs[0:48])
fmt.Printf("MQINQ returned +%v %s \n",
intAttrs, string(charAttrs))
fmt.Printf(" '%s'\n", returnedName)
}
}
// MQDISC regardless of other errors
if connected {
err = qMgr.Disc()
fmt.Println("Disconnected from queue manager ", qMgrName)
}
if err == nil {
os.Exit(0)
} else {
mqret := err.(*ibmmq.MQReturn)
os.Exit((int)(mqret.MQCC))
}
}