Skip to content

Commit f70c61c

Browse files
authored
code snippets language specified in README
1 parent aaf8fcf commit f70c61c

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

README.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ in this JMS 2.0 style interface in Golang. Note that there are additional workin
3535
### Send and receive a message containing a text string
3636
(from [sample_sendreceive_test.go](sample_sendreceive_test.go))
3737
Note that for illustration purposes this sample only has limited error handling, which you should never do in production application code! Please see the TestSampleSendReceiveWithErrorHandling function for an equivalent sample that demonstrates good practice for error handling.
38-
```
38+
```golang
3939
// Create a ConnectionFactory using details stored in some external property files
4040
cf, cfErr := mqjms.CreateConnectionFactoryFromDefaultJSONFiles()
4141
if cfErr != nil {
@@ -79,14 +79,14 @@ if rcvBody != nil {
7979

8080
### Send a non-persistent message
8181
(from [deliverymode_test.go](deliverymode_test.go))
82-
```
82+
```golang
8383
msgBody = "My non-persistent message"
8484
err3 := context.CreateProducer().SetDeliveryMode(jms20subset.DeliveryMode_NON_PERSISTENT).SendString(queue, msgBody)
8585
```
8686

8787
### Error handling
8888
(from [sample_errorhandling_test.go](sample_errorhandling_test.go))
89-
```
89+
```golang
9090
// Create a ConnectionFactory using some property files
9191
cf, cfErr := mqjms.CreateConnectionFactoryFromDefaultJSONFiles()
9292
assert.Nil(t, cfErr)
@@ -122,7 +122,7 @@ your own error handling or logging.
122122
* Handle error codes returned by the queue manager - [sample_errorhandling_test.go](sample_errorhandling_test.go)
123123

124124
As normal with Go, you can run any individual testcase by executing a command such as;
125-
```
125+
```bash
126126
go test -run TestSampleSendReceiveWithErrorHandling
127127
```
128128

@@ -142,7 +142,7 @@ The IBM MQ client on which this library depends is supported on Linux and Window
142142
- Simply unzip the archive and make a note of the installation location. For ease of configuration you may wish to unzip the archive into the default install IBM MQ location for your platform
143143
- Note that v9.1.1 (CD) or higher of the MQ client library is required as it includes header files that are not present in v9.1.0 LTS or below.
144144
4. Git clone this project to download this JMS style implementation onto your workstation
145-
```
145+
```bash
146146
# Update and set the GOPATH variable to match your workspace
147147
export GOPATH=/home/myuser/workspace
148148

@@ -159,7 +159,7 @@ The IBM MQ client on which this library depends is supported on Linux and Window
159159
### Configuring your environment
160160

161161
First you must configure your command console environment as described in the [mq-golang Getting Started instructions](https://github.com/ibm-messaging/mq-golang#getting-started) so that the necessary flags are set;
162-
```
162+
```bash
163163
# Configure your Go environment variables (update to match your own setup)
164164
export GOROOT=/usr/local/go
165165
export GOPATH=/home/myuser/workspace
@@ -171,20 +171,20 @@ export CGO_LDFLAGS_ALLOW="-Wl,-rpath.*"
171171

172172

173173
**If your client install is not located in the default installation location**, for example `/opt/mqm` then you also need to set the follow environment variables to point at your installation location. For example on Linux or MacOS;
174-
```
174+
```bash
175175
export MQ_INSTALLATION_PATH=$HOME/9.1.1.0-IBM-MQC-Redist-LinuxX64
176176
export CGO_CFLAGS="-I$MQ_INSTALLATION_PATH/inc"
177177
export CGO_LDFLAGS="-L$MQ_INSTALLATION_PATH/lib64 -Wl,-rpath,$MQ_INSTALLATION_PATH/lib64"
178178
```
179179

180180
Download the Golang modules on which this project depends by running the dep command;
181-
```
181+
```bash
182182
cd $GOPATH/src/github.com/ibm-messaging/mq-golang-jms20/
183183
dep ensure
184184
```
185185

186186
Confirm the settings are correct by compiling the MQ JMS Golang package, for example as follows; (no errors will be shown if successful)
187-
```
187+
```bash
188188
cd $GOPATH/src/github.com/ibm-messaging/mq-golang-jms20/mqjms/
189189
go build
190190
```
@@ -203,7 +203,7 @@ The test cases use the `CreateConnectionFactoryFromDefaultJSONFiles` method to o
203203
Once you have added the details of your queue manager and user credentials into the two JSON files and placed them in your `/Downloads` directory you are ready to run the test, which is done in the same way as any other Go tests.
204204

205205
Note that the tests require the queues `DEV.QUEUE.1` and `DEV.QUEUE.2` to be defined on your queue manager, be empty of messages and be accessible to the application username you are using. This will be the case by default for queue managers provisioned through the MQ on Cloud service, but may require manual configuration for queue managers you have created through other means.
206-
```
206+
```bash
207207
> cd $GOPATH/src/github.com/ibm-messaging/mq-golang-jms20/
208208
> go test -v
209209

@@ -218,10 +218,9 @@ ok github.com/ibm-messaging/mq-golang-jms20 11.308s
218218

219219
### Writing your own Golang application that talks to IBM MQ
220220
Writing your own application to talk to IBM MQ is simple - as shown in the [sample_sendreceive_test.go](sample_sendreceive_test.go) sample. Simply import this module into your source file, and get started!
221-
```
221+
```golang
222222
import (
223223
"github.com/ibm-messaging/mq-golang-jms20/mqjms"
224-
225224
)
226225
```
227226

@@ -234,7 +233,7 @@ The first thing you'll need to do is create a ConnectionFactory object so that y
234233
2. Create a new ConnectionFactory object and set the variables in your application code
235234
- This is a quick and easy way to get started, but less desirable for production quality applications
236235
- You can hardcode the values in your source file, or perhaps look them up from environment variables as shown below
237-
```
236+
```golang
238237
cf := mqjms.ConnectionFactoryImpl{
239238
QMName: "QM_ONE",
240239
Hostname: "random.hostname.com",

0 commit comments

Comments
 (0)