100% found this document useful (2 votes)
301 views67 pages

Distributed Computing With Go 1st Edition V.N. Nikhil Anurag download

The document provides an overview of the book 'Distributed Computing with Go' by V.N. Nikhil Anurag, which focuses on practical concurrency and parallelism in Go applications. It outlines the book's structure, including chapters on goroutines, channels, RESTful web services, and building a distributed search engine. The book is intended for developers familiar with Go syntax and basic development concepts.

Uploaded by

panikokuna7y
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
301 views67 pages

Distributed Computing With Go 1st Edition V.N. Nikhil Anurag download

The document provides an overview of the book 'Distributed Computing with Go' by V.N. Nikhil Anurag, which focuses on practical concurrency and parallelism in Go applications. It outlines the book's structure, including chapters on goroutines, channels, RESTful web services, and building a distributed search engine. The book is intended for developers familiar with Go syntax and basic development concepts.

Uploaded by

panikokuna7y
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 67

Distributed Computing With Go 1st Edition V.N.

Nikhil Anurag download

https://textbookfull.com/product/distributed-computing-with-
go-1st-edition-v-n-nikhil-anurag/

Download more ebook from https://textbookfull.com


We believe these products will be a great fit for you. Click
the link to download now, or visit textbookfull.com
to discover even more!

Distributed Services with Go Your Guide to Reliable


Scalable and Maintainable Systems 1st Edition Travis
Jeffery

https://textbookfull.com/product/distributed-services-with-go-
your-guide-to-reliable-scalable-and-maintainable-systems-1st-
edition-travis-jeffery/

Silicon Photonics amp High Performance Computing


Proceedings of CSI 2015 1st Edition Anurag Mishra

https://textbookfull.com/product/silicon-photonics-amp-high-
performance-computing-proceedings-of-csi-2015-1st-edition-anurag-
mishra/

Distributed Computing Pearls 1st Edition Gadi


Taubenfeld

https://textbookfull.com/product/distributed-computing-
pearls-1st-edition-gadi-taubenfeld/

Internet and Distributed Computing Systems Giancarlo


Fortino

https://textbookfull.com/product/internet-and-distributed-
computing-systems-giancarlo-fortino/
Beginning Jenkins Blue Ocean: Create Elegant Pipelines
With Ease 1st Edition Nikhil Pathania

https://textbookfull.com/product/beginning-jenkins-blue-ocean-
create-elegant-pipelines-with-ease-1st-edition-nikhil-pathania/

Security with Go 1st Edition John Daniel Leon

https://textbookfull.com/product/security-with-go-1st-edition-
john-daniel-leon/

Intelligent Distributed Computing X: Proceedings of the


10th International Symposium on Intelligent Distributed
Computing – IDC 2016, Paris, France, October 10-12 2016
1st Edition Costin Badica
https://textbookfull.com/product/intelligent-distributed-
computing-x-proceedings-of-the-10th-international-symposium-on-
intelligent-distributed-computing-idc-2016-paris-france-
october-10-12-2016-1st-edition-costin-badic/

Distributed Computing by Mobile Entities Current


Research in Moving and Computing Paola Flocchini

https://textbookfull.com/product/distributed-computing-by-mobile-
entities-current-research-in-moving-and-computing-paola-
flocchini/

Distributed Computing and Artificial Intelligence 12th


International Conference 1st Edition Sigeru Omatu

https://textbookfull.com/product/distributed-computing-and-
artificial-intelligence-12th-international-conference-1st-
edition-sigeru-omatu/
Distributed Computing with Go

Practical concurrency and parallelism for Go applications

V.N. Nikhil Anurag

BIRMINGHAM - MUMBAI
Distributed Computing with Go
Copyright © 2018 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form
or by any means, without the prior written permission of the publisher, except in the case of brief quotations
embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented.
However, the information contained in this book is sold without warranty, either express or implied. Neither the
author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to
have been caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products
mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy
of this information.

Commissioning Editor: Dominic Shakeshaft


Acquisition Editor: Frank Pohlmann
Project Editor: Radhika Atitkar
Content Development Editor: Monika Sangwan
Technical Editor: Nidhisha Shetty
Copy Editor: Tom Jacob
Proofreader: Safis Editing
Indexer: Rekha Nair
Graphics: Tom Scaria
Production Coordinator: Nilesh Mohite

First published: February 2018

Production reference: 1270218

Published by Packt Publishing Ltd.


Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.

ISBN 978-1-78712-538-4

www.packtpub.com
mapt.io

Mapt is an online digital library that gives you full access to over 5,000 books and videos, as
well as industry leading tools to help you plan your personal development and advance
your career. For more information, please visit our website.

Why subscribe?
Spend less time learning and more time coding with practical eBooks and Videos
from over 4,000 industry professionals

Improve your learning with Skill Plans built especially for you

Get a free eBook or video every month

Mapt is fully searchable

Copy and paste, print, and bookmark content

PacktPub.com
Did you know that Packt offers eBook versions of every book published, with PDF and
ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a
print book customer, you are entitled to a discount on the eBook copy. Get in touch with us
at [email protected] for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a
range of free newsletters, and receive exclusive discounts and offers on Packt books and
eBooks.
Contributors

About the author


V.N. Nikhil Anurag is a Go developer currently working in Berlin. He speaks at
conferences about how to use Go in domains such as concurrency, file systems, and
distributed systems. He is also trying to bridge the gap between the rich literature on
concurrency and the practice of programming goroutines and channels. He did his
Bachelor's in Electronics and Instrumentation Engineering from JNTU, India and Master of
Science in Control System from University of Sheffield, UK.
About the reviewers
Pankaj Khairnar is a cofounder and CTO at Qwentic (A Golang specialized development
company). He loves programming, and for the last 10 years, he has been developing highly
scalable and distributed enterprise applications using various technologies.

I would like to thank my wife and friends for their support.

Jinzhu Zhang is a veteran coder, creator/contributor of many open source projects, such as
GORM. He is on Github at github.com/jinzhu.

Packt is searching for authors like you


If you're interested in becoming an author for Packt, please visit authors.packtpub.com and
apply today. We have worked with thousands of developers and tech professionals, just
like you, to help them share their insight with the global tech community. You can make a
general application, apply for a specific hot topic that we are recruiting an author for, or
submit your own idea.
Table of Contents
Preface 1

Chapter 1: Developer Environment for Go 7


GOROOT 7
GOPATH 8
src/ 8
pkg/ 8
bin/ 9
Package management 10
go get 10
glide 11
go dep 11
Structuring a project 12
Working with book's code 12
Containers 13
Docker 14
Docker versus Virtual Machine (VM) 14
Understanding Docker 15
Testing Docker setup 17
Dockerfile 19
main.go 19
Testing in Go 20
variadic.go 21
variadic_test.go 22
Running tests in variadic_test.go 23
addInt.go 24
addInt_test.go 24
Running tests in addInt_test.go 25
nil_test.go 26
Running tests in nil_test.go 28
Summary 28
Chapter 2: Understanding Goroutines 29
Table of Contents

Concurrency and parallelism 29


Concurrency 30
Code overview 32
Serial task execution 32
Serial task execution with goroutines 34
Concurrent task execution 37
Parallelism 38
Go's runtime scheduler 40
Goroutine 40
OS thread or machine 41
Context or processor 42
Scheduling with G, M, and P 42
Gotchas when using goroutines 49
Single goroutine halting the complete program 49
Goroutines aren't predictable 51
Summary 52
Chapter 3: Channels and Messages 53
Controlling parallelism 53
Distributed work without channels 56
Distributed work with channels 60
What is a channel? 60
Solving the cashier problem with goroutines 61
Channels and data communication 62
Messages and events 64
Types of channels 64
The unbuffered channel 65
The buffered channel 65
The unidirectional buffer 67
Closing channels 69
Multiplexing channels 72
Summary 76
Chapter 4: The RESTful Web 77
HTTP and sessions 78
A brief history of HTTP 78
HTTP sessions 79

[ ii ]
Table of Contents

The REST protocol 79


The server and client architecture 80
The standard data format 80
Resources 80
Reusing the HTTP protocol 81
GET 81
POST 81
PUT and PATCH 81
DELETE 82
Upgradable components 82
Fundamentals of a REST server 82
A simple web server 82
Designing a REST API 83
The data format 84
The book resource 84
GET /api/books 84
GET /api/books/<id> 85
POST /api/books 85
PUT /api/books/<id> 86
DELETE /api/books/<id> 86
Unsuccessful requests 87
Design decisions 87
The REST server for books API 87
main.go 88
books-handler/common.go 89
books-handler/actions.go 91
books-handler/handler.go 93
How to make REST calls 96
cURL 96
GET 97
DELETE 98
PUT 99
POST 100
Postman 102
net/http 105
Summary 107
Chapter 5: Introducing Goophr 108
What is Goophr? 108

[ iii ]
Table of Contents

Design overview 109


OpenAPI specification 110
Goophr Concierge API definition 113
Goophr Librarian API definition 116
Project structure 120
Summary 123
Chapter 6: Goophr Concierge 124
Revisiting the API definition 124
Document feeder – the REST API endpoint 126
Query handler – the REST API endpoint 127
Conventions 128
Code conventions 128
Diagram conventions 129
Logical flow diagrams 130
The doc processor 130
The doc store 131
The index processor 132
The line store 133
The consolidated flow diagram 135
Queue workers 135
Single stores 136
Buffered channels 136
The Concierge source code 136
Running tests 147
The Concierge server 148
Summary 149
Chapter 7: Goophr Librarian 150
The standard indexing model 150
An example – books with an index of words 151
The inverted indexing model 152
An example – the inverted index for words in books 152
Ranking 153
Revisiting the API definition 153
The document indexer – the REST API endpoint 156

[ iv ]
Table of Contents

The query resolver – the REST API endpoint 157


Code conventions 157
Librarian source code 157
main.go 158
common/helpers.go 158
api/index.go 159
api/query.go 162
Testing Librarian 166
Testing feeder.go using /api/index 166
Testing /api/query 168
Summary 170
Chapter 8: Deploying Goophr 171
Updating Goophr Concierge 171
Handle multiple Librarians 172
Aggregated search results 172
Orchestrating with docker-compose 173
Environment variables and API ports 173
The file server 173
The Goophr source code 174
librarian/main.go 174
concierge/main.go 175
concierge/api/query.go 176
simple-server/Dockerfile 179
simple-server/main.go 180
docker-compose.yaml 180
.env 181
Running Goophr with docker-compose 183
Adding documents to Goophr 184
Searching for keywords with Goophr 186
Search – "apple" 186
Search – "cake" 187
Search – "apple", "cake" 188
Individual logs with docker-compose 189
Authorization on a web server 190
secure/secure.go 190

[v]
Table of Contents

secure/secure_test.go 192
Test results 194
Summary 195
Chapter 9: Foundations of Web Scale Architecture 196
Scaling a web application 197
The single server instance 197
Separate layers for the web and database 198
Multiple server instances 200
The load balancer 200
Multi-availability zones 202
The database 203
SQL versus NoSQL 204
Which type of database should we use? 204
Database replication 205
Master-replica replication 205
Master-master replication 209
Failover cluster replication 214
Monolith versus microservices 216
Mediator design pattern 217
Deployment options 219
Maintainability of multiple instances 220
Summary 221
Other Books You May Enjoy 222

Index 226

[ vi ]
Preface
The Go programming language was developed at Google to solve the problems they faced
while developing software for their infrastructure. They needed a language that was
statically typed without slowing down the developer, would compile and execute
instantaneously, take advantage of multicore processors, and make working across
distributed systems, effortless.

The mission of Distributed computing with Go is to make reasoning about concurrency


and parallelism, effortless and provide the reader with the confidence to design and
implement such programs in Go. We will start by digging into the core concepts behind
goroutines and channels, the two fundamental concepts in Go around which the language
is built. Next, we will design and build a distributed search engine using Go and Go's
standard library.

Who this book is for


This book is for developers who are familiar with the Golang syntax and have a good idea
of how basic Go development works. It would be advantageous if you have been through a
web application product cycle, although it's not necessary.

What this book covers


Chapter 1, Developer Environment for Go, covers a list of topics and concepts required to start
working with Go and rest of the book. Some of these topics include Docker and testing in
Go.

Chapter 2, Understanding Goroutines, introduces the topic of concurrency and parallelism


and then dives deep into the implementation details of goroutines, Go's runtime scheduler,
and many more.

Chapter 3, Channels and Messages, begins by explaining the complexity of controlling


parallelism before introducing strategies to control parallelism, using different types of
channels.
Preface

Chapter 4, The RESTful Web, provides all the context and knowledge required to start
designing and building REST APIs in Go. We will also discuss the interaction with a REST
API server using different available approaches.

Chapter 5, Introducing Goophr, opens the discussion on what is meant by a distributed


search engine, using OpenAPI specification to describe REST APIs and describing the
responsibilities of the components of a search engine, using OpenAPI. Finally, we'll describe
the project structure.

Chapter 6, Goophr Concierge, dives deep into the first component of Goophr by describing in
detail how the component is supposed to work. These concepts are further driven home
with the help of architectural and logical flow diagrams. Finally, we'll look at how to
implement and test the component.

Chapter 7, Goophr Librarian, is a detailed look at the component that is responsible for
maintaining the index for the search terms. We also look at how to search for given terms
and how to order our search results and many more. Finally, we'll look at how to
implement and test the component.

Chapter 8, Deploying Goophr, brings together everything we have implemented in the


previous three chapters and start the application on the local system. We will then test our
design by adding a few documents and searching against them via the REST API.

Chapter 9, Foundations of Web Scale Architecture, is an introduction to the vast and complex
topic on how to design and scale a system to meet with the demands at web scale. We will
start with a single instance of a monolith running on a single server and scale it up to span
across multiple region, have redundancy safeguards to ensure that the service is never
down and many more.

To get the most out of this book


The material in the book is designed to enable a hands-on approach. Throughout
the book, a conscious effort has been made to provide all the relevant information
to the reader beforehand so that, if the reader chooses, they can try to solve the
problem on their own and then refer to the solution provided in the book.
The code in the book does not have any Go dependencies beyond the standard
library. This is done in order to ensure that the code examples provided in the
book never change, and this also allows us to explore the standard library.

[2]
Preface

The source code in the book should be placed at $GOPATH/src/distributed-


go. The source code for examples given will be located inside
the $GOPATH/src/distributed-go/chapterX folder, where X stands for the
chapter number.
Download and install Go from https:/​/​golang.​org/​ and Docker from https:/​/
www.​docker.​com/​community-​edition website

Download the example code files


You can download the example code files for this book from your account at
http://www.packtpub.com. If you purchased this book elsewhere, you can visit
http://www.packtpub.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

1. Log in or register at http://www.packtpub.com.


2. Select the SUPPORT tab.
3. Click on Code Downloads & Errata.
4. Enter the name of the book in the Search box and follow the on-screen
instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the
latest version of:

WinRAR / 7-Zip for Windows


Zipeg / iZip / UnRarX for Mac
7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https:/​/​github.​com/
PacktPublishing/​Distributed-​Computing-​with-​Go. In case there's an update to the code, it
will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at
https://github.com/PacktPublishing/. Check them out!

[3]
Preface

Download the color images


We also provide a PDF file that has color images of the screenshots/diagrams used in this
book. You can download it here:
https://www.packtpub.com/sites/default/files/downloads/DistributedComputingwith
Go_ColorImages.pdf.

Conventions used
There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames,
file extensions, pathnames, dummy URLs, user input, and Twitter handles. For example,
"Now that we have all the code in place, let's build the Docker image using
the Dockerfile file."

A block of code is set as follows:


// addInt.go

package main

func addInt(numbers ...int) int {


sum := 0
for _, num := range numbers {
sum += num
}
return sum
}

When we wish to draw your attention to a particular part of a code block, the relevant lines
or items are set in bold:
// addInt.go

package main

func addInt(numbers ...int) int {


sum := 0
for _, num := range numbers {
sum += num
}
return sum
}

[4]
Preface

Any command-line input or output is written as follows:


$ cd docker

Bold: Indicates a new term, an important word, or words that you see on the screen, for
example, in menus or dialog boxes, also appear in the text like this. For example, "Select
System info from the Administration panel."

[5]
Preface

Warnings or important notes appear like this.

Tips and tricks appear like this.

Get in touch
Feedback from our readers is always welcome.

General feedback: Email [email protected], and mention the book's title in the
subject of your message. If you have questions about any aspect of this book, please email
us at [email protected].

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes
do happen. If you have found a mistake in this book we would be grateful if you would
report this to us. Please visit, http://www.packtpub.com/submit-errata, selecting your
book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the internet, we
would be grateful if you would provide us with the location address or website name.
Please contact us at [email protected] with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in
and you are interested in either writing or contributing to a book, please visit
http://authors.packtpub.com.

Reviews
Please leave a review. Once you have read and used this book, why not leave a review on
the site that you purchased it from? Potential readers can then see and use your unbiased
opinion to make purchase decisions, we at Packt can understand what you think about our
products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit packtpub.com.

[6]
Developer Environment for Go
1
Go is a modern programming language built for the 21st century application development.
Hardware and technology have advanced significantly over the past decade, and most of
the other languages do not take advantage of these technical advancements. As we shall see
throughout the book, Go allows us to build network applications that take advantage of
concurrency and parallelism made available with multicore systems.

In this chapter, we will look at some of the topics required to work through rest of the book,
such as:

Go configuration—GOROOT, GOPATH, and so on.


Go package management
Project structure used throughout the book
Container technology and how to use Docker
Writing tests in Go

GOROOT
In order to run or build a Go project, we need to have access to the Go binary and its
libraries. A typical installation of Go (instructions can be found
at https://golang.org/dl/) on Unix-based systems will place the Go binary at
/usr/bin/go. However, it is possible to install Go on a different path. In that case, we need
to set the GOROOT environment variable to point to our Go installation path and also append
it to our PATH environment variable.
Developer Environment for Go Chapter 1

GOPATH
Programmers tend to work on many projects and it is good practice to have the source code
separate from nonprogramming-related files. It is a common practice to have the source
code in a separate location or workspace. Every programming language has its own
conventions on how the language-related projects should be set up and Go is no exception
to this.

GOPATH is the most important environment variable the developer has to set. It tells the Go
compiler where to find the source code for the project and its dependencies. There are
conventions within the GOPATH that need to be followed, and they have to deal with folder
hierarchies.

src/
This is the directory that will contain the source code of our projects and their
dependencies. In general, we want our source code to have version control and be hosted
on the cloud. It would also be great if we or anyone else could easily use our project. This
requires a little extra setup on our part.

Let's imagine that our project is hosted at


http://git-server.com/user-name/my-go-project. We want to clone and build this
project on our local system. To make it properly work, we need to clone it to
$GOPATH/src/git-server.com/user-name/my-go-project. When we build a Go
project with dependencies for the first time, we will see that the src/ folder has many
directories and subdirectories that contain the dependencies of our project.

pkg/
Go is a compiled programming language; we have the source code and code for the
dependencies that we want to use in our project. In general, every time we build a binary,
the compiler has to read the source code of our project and dependencies and then compile
it to machine code. Compiling unchanged dependencies every time we compile our main
program would lead to a very slow build process. This is the reason that object files exist;
they allow us to compile dependencies into reusable machine code that can be readily
included in our Go binary.

[8]
Developer Environment for Go Chapter 1

These object files are stored in $GOPATH/pkg; they follow a directory structure similar to
that of src/, except that they are within a subdirectory. These directories tend to follow the
naming pattern of <OS>_<CPU-Architecture>, because we can build executable binaries
for multiple systems:
$ tree $GOPATH/pkg
pkg
└── linux_amd64
├── github.com
│ ├── abbot
│ │ └── go-http-auth.a
│ ├── dimfeld
│ │ └── httppath.a
│ ├── oklog
│ │ └── ulid.a
│ ├── rcrowley
│ │ └── go-metrics.a
│ ├── sirupsen
│ │ └── logrus.a
│ ├── sony
│ │ └── gobreaker.a
└── golang.org
└── x
├── crypto
│ ├── bcrypt.a
│ ├── blowfish.a
│ └── ssh
│ └── terminal.a
├── net
│ └── context.a
└── sys

bin/
Go compiles and builds our projects into executable binaries and places them in this
directory. Depending on the build specs, they might be executable on your current system
or other systems. In order to use the binaries that are available in the bin/ directory, we
need to set the corresponding GOBIN=$GOPATH/bin environment variable.

[9]
Developer Environment for Go Chapter 1

Package management
In the days of yore, all programs were written from scratch—every utility function and
every library to run the code had to written by hand. Now a days, we don't want to deal
with the low level details on a regular basis; it would be unimaginable to write all the
required libraries and utilities from scratch. Go comes with a rich library, which will be
enough for most of our needs. However, it is possible that we might need a few extra
libraries or features not provided by the standard library. Such libraries should be available
on the internet, and we can download and add them into our project to start using them.

In the previous section, GOPATH, we discussed how all our projects are saved into
qualified paths of the $GOPATH/src/git-server.com/user-name/my-go-
project form. This is true for any and all dependencies we might have. There are multiple
ways to handle dependencies in Go. Let's look at some of them.

go get
The go get is the utility provided by the standard library for package management. We
can install a new package/library by running the following command:
$ go get git-server.com/user-name/library-we-need

This will download and build the source code and then install it as a binary executable (if it
can be used as a standalone executable). The go get utility also installs all the
dependencies required by the dependency retrieved for our project.

The go get utility is a very simple tool. It will install the latest master
commit on the Git repository. For simple projects, this might be enough.
However, as projects start growing in size and complexity, keeping track
of the version of dependency being used might become critical.
Unfortunately, go get is not great for such projects, and we might want
to look at other package management tools.

[ 10 ]
Developer Environment for Go Chapter 1

glide
The glide is one of the most widely used package management tool in Go community. It
addresses the limitations of go get, but it needs to be installed manually by the developer.
The following is a simple way to install and use glide:
$ curl https://glide.sh/get | sh
$ mkdir new-project && cd new-project
$ glide create
$ glide get github.com/last-ent/skelgor # A helper project to generate
project skeleton.
$ glide install # In case any dependencies or configuration were manually
added.
$ glide up # Update dependencies to latest versions of the package.
$ tree
.
├── glide.lock
├── glide.yaml
└── vendor
└── github.com
└── last-ent
└── skelgor
├── LICENSE
├── main.go
└── README.md

In case you do not wish to install glide via curl and sh, other options are available and
described in better detail on the project page, available
at https://github.com/masterminds/glide.

go dep
The go dep is a new dependency management tool being developed by the Go community.
Right now, it requires Go 1.7 or newer to compile, and it is ready for production use.
However, it is still undergoing changes and hasn't yet been merged into Go's standard
library.

[ 11 ]
Developer Environment for Go Chapter 1

Structuring a project
A project might have more than just the source code for the project, for example,
configuration files and project documentation. Depending upon preferences, the way the
project is structured can drastically change. However, the most important thing to
remember is that the entry point to the whole program is through the main function, which
is implemented within main.go as a convention.

The application we will be building in this book, will have the following initial structure:
$ tree
.
├── common
│ ├── helpers.go
│ └── test_helpers.go
└── main.go

Working with book's code


The source code discussed throughout the book can be obtained in two ways:

Using go get -u github.com/last-ent/distributed-go


Downloading the code bundle from the website and extracting it to
$GOPATH/src/github.com/last-ent/distributed-go

The code for complete book should now be available at $GOPATH/src/github.com/last-


ent/distributed-go and the code specific for each chapter will be available in that
particular chapter number's directory.

For example,

Code for Chapter 1 -> $GOPATH/src/github.com/last-ent/distributed-


go/chapter1

Code for Chapter 2 -> $GOPATH/src/github.com/last-ent/distributed-


go/chapter2

And so on.

Whenever we discuss code in any particular chapter, it is implied that we are in the
respective chapter's folder.

[ 12 ]
Developer Environment for Go Chapter 1

Containers
Throughout the book, we will be writing Go programs that will be compiled to binaries and
run directly on our system. However, in the latter chapters we will be using docker-
compose to build and run multiple Go applications. These applications can run without any
real problem on our local system; however, our ultimate goal is to be able to run these
programs on servers and to be able to access them over the internet.

During the 1990s and early 2000s, the standard way to deploy applications to the internet
was to get a server instance, copy the code or binary onto the instance, and then start the
program. This worked great for a while, but soon complications began to arise. Here are a
few of them:

Code that worked on the developer's machine might not work on the server.
Programs that ran perfectly on a server instance might fail upon applying the
latest patch to the server's OS.
For every new instance added as part of a service, various installation scripts had
to be run so that we can bring the new instance to be on par with all the other
instances. This can be a very slow process.
Extra care had to be taken to ensure that the new instance and all the software
versions installed on it are compatible with the APIs being used by our program.
It was also important to ensure that all config files and important environment
variables were copied to the new instance; otherwise, the application might fail
with little or no clue.
Usually the version of the program that ran on local system versus test system
versus production system were all configured differently, and this meant that it
was possible for our application to fail on one of the three types of systems. If
such a situation occurred, we would end up having to spend extra time and effort
trying to figure out whether the issue is specific to one particular instance, one
particular system, and so on.

It would be great if we could avoid such a situation from arising, in a sensible manner.
Containers try to solve this problem using OS-level virtualization. What does this mean?

[ 13 ]
Developer Environment for Go Chapter 1

All programs and applications are run in a section of memory known as user space. This
allows the operating system to ensure that a program is not able to cause major hardware or
software issues. This allows us to recover from any program crashes that might occur in the
user space applications.

The real advantage of containers is that they allow us to run applications in isolated user
spaces, and we can even customize the following attributes of user spaces:

Connected devices such as network adapters and TTY


CPU and RAM resources
Files and folders accessible from host OS

However, how does this help us solve the problems we stated earlier? For that, let's take a
deeper look at Docker.

Docker
Modern software development makes extensive use of containers for product development
and product deployment to server instances. Docker is a container technology promoted by
Docker, Inc (https://www.docker.com), and as of this writing, it is the most predominantly
used container technology. The other major alternative is rkt developed by CoreOS
(https://coreos.com/rkt), though in this book, we will only be looking at Docker.

Docker versus Virtual Machine (VM)


Looking at the description of Docker so far, we might wonder if it is yet another Virtual
Machine. However, this is not the case, because a VM requires us to run a complete guest
OS on top of our machine, or hypervisor, as well as all the required binaries. In the case of
Docker, we use OS level virtualization, which allows us to run our containers in isolated
user spaces.

[ 14 ]
Developer Environment for Go Chapter 1

The biggest advantage of a VM is that we can run different types of OSes on a system, for
example, Windows, FreeBSD, and Linux. However, in the case of Docker, we can run any
flavor of Linux, and the only limitation is that it has to be Linux:

Docker container versus VM

The biggest advantage of Docker containers is that since it runs natively on Linux as a
discrete process making it lightweight and unaware of all the capabilities of the host OS.

Understanding Docker
Before we start using Docker, let's take a brief look at how the Docker is meant to be used,
how it is structured, and what are the major components of the complete system.

The following list and the accompanying image should help understand the architecture of
Docker pipeline:

Dockerfile: It consists of instructions on how to build an image that runs our


program.
Docker client: This is a command-line program used by the user to interact with
Docker daemon.

[ 15 ]
Developer Environment for Go Chapter 1

Docker daemon: This is the Daemon application that listens for commands to
manage building or running containers and pushing containers to Docker
registry. It is also responsible for configuring container networks, volumes, and
so on.
Docker images: Docker images contain all the steps necessary to build a
container binary that can be executed on any Linux machine with Docker
installed.
Docker registry: The Docker registry is responsible for storing and retrieving the
Docker images. We can use a public Docker registry or a private one. Docker Hub
is used as the default Docker registry.
Docker Container: The Docker container is different from the Container we have
been discussing so far. A Docker container is a runnable instance of a Docker
image. A Docker container can be created, started, stopped, and so on.
Docker API: The Docker client we discussed earlier is a command-line interface
to interact with Docker API. This means that the Docker daemon need not be
running on the same machine as does the Docker client. The default setup that we
will be using throughout the book talks to the Docker daemon on the local system
using UNIX sockets or a network interface:

Docker architecture

[ 16 ]
Developer Environment for Go Chapter 1

Testing Docker setup


Let's ensure that our Docker setup works perfectly. For our purpose, Docker Community
Edition should suffice (https://www.docker.com/community-edition). Once we have it
installed, we will check if it works by running a few basic commands.

Let's start by checking what version we have installed:


$ docker --version
Docker version 17.12.0-ce, build c97c6d6

Let's try to dig deeper into details about our Docker installation:
$ docker info
Containers: 38
Running: 0
Paused: 0
Stopped: 38
Images: 24
Server Version: 17.12.0-ce

On Linux, when you try to run docker commands, you might get
Permission denied error. In order to interact with Docker, you can either
prefix the command with sudo or you can create a "docker" user group
and add your user to this group. See link for more details https:/​/​docs.
docker.​com/​install/​linux/​linux-​postinstall/​.​

Let's try to run a Docker image. If you remember the discussion regarding the Docker
registry, you know that we do not need to build a Docker image using Dockerfile, to run a
Docker container. We can directly pull it from Docker Hub (the default Docker registry) and
run the image as a container:
$ docker run docker/whalesay cowsay Welcome to GopherLand!

Unable to find image 'docker/whalesay:latest' locally


Trying to pull repository docker.io/docker/whalesay ...
sha256:178598e51a26abbc958b8a2e48825c90bc22e641de3d31e18aaf55f3258ba93b:
Pulling from docker.io/docker/whalesay
e190868d63f8: Pull complete
909cd34c6fd7: Pull complete
0b9bfabab7c1: Pull complete
a3ed95caeb02: Pull complete
00bf65475aba: Pull complete
c57b6bcc83e3: Pull complete
8978f6879e2f: Pull complete
8eed3712d2cf: Pull complete

[ 17 ]
Another Random Document on
Scribd Without Any Related Topics
leading downward. Gale listened intently and when she heard
nothing that indicated another’s presence, descended into the
passage. It was nothing like the big coal mines she had read and
seen pictures of. It was merely a tunnel that had been hewed out of
the ground with pick and shovel. If the ground had once held a
fortune of silver, it gave no evidence of it now. She had to stoop, so
low was the ceiling, as she picked her way along over rocks and
débris.
Suddenly the thin ray of light from her lamp wavered and she
noticed that it had grown dim. The battery was growing weak and
would not last much longer. She switched it off. She must save it so
she would have at least enough light to find her way back to the
entrance. That was where she made her mistake. Creeping along in
darkness, she did not see the black hole ahead and when her foot
touched empty air, fell head foremost down--down--several feet.
For a moment she lay stunned with the unexpectedness of her fall.
Too, the jar of landing had knocked all collected thought from her
head. Slowly she sat up and felt for an injury. Nothing but bruises,
thank goodness. She had dropped her flashlight and had to feel out
with her hands along the damp earth until she found it. She hoped
fervently that the drop had not put it entirely out of commission. No,
when she pressed the little button, a feeble ray of light shot out. The
light was bright enough to see that she had fallen into a pit of some
sort that stretched away out behind her into darkness which the
lamp would not penetrate.
She got to her feet and endeavored to shake some of the dirt from
her clothes. It was a risk to go forward without a light, but a glance
at the wall of dirt and rock had shown her that she could never hope
to climb up to where she had been before her fall. There was no
course but to explore this passage here and to hope that that
mysterious shadow did not decide to come back into the mine
immediately. But perhaps he had friends in here, friends that would
not welcome her intrusion. The very thought that any minute she
might stumble upon some mysterious, fearful unknown made her
nervous and she proceeded with greater caution.
Gale endeavored to readjust her sense of direction, which had been
somewhat confused with her fall, to find in what direction this
passage led. If she was correct, and she believed she was, it should
lead across to directly beneath the cabin where her friends were
sleeping. In that case, the man she had seen might have been the
“ghost” who with his mysterious knocks and screams had frightened
them. But, remembering the fall which she had had, how did he get
down to this lower passage, and once down here, how did he get up
again? She had not been able to find any means of gaining the
higher level. She halted and switched her flashlight on again. The
light was failing rapidly and she dared to keep it on only a moment.
But in that moment she had switched it overhead and seen the row
of four or five boards which she was sure were part of the floor of
the cabin. She sought a rock and hurled it up against the boards,
ducking as it rebounded back at her. She followed it with another
and then another.
“The ghost is back again,” said a nervous voice which she recognized
as Janet’s.
Certainly it was the floor of the cabin and she had discovered how
the ghost had done his mysterious knocking. His voice from here
would have been clearly audible to them, too, just as she could hear
the girls now.
“Gale’s gone!” she heard Valerie cry in alarm.
“Gone!” the others echoed.
She was just about to call out to reassure them when a sound in the
passageway behind her made her hold her breath in suspense.
Someone was coming along the tunnel. That must mean that the
mysterious ghost had returned to do some more of his haunting.
With quick and as quiet steps as possible, she retreated back the
way she had come, and directly toward that unknown. Standing
flattened against the earth wall, her heart thumping so she was sure
he would hear it, Gale waited for the ghost to pass her. He did so,
actually brushing against her in the darkness. He carried no
flashlight and it was this fact alone that had saved her from
discovery. Evidently he knew his way about in the darkness.
Aided now by fear, she sped along the narrow, low tunnel to where
she had had her fall. The man certainly had not been in here when
she fell, hence there must be some way he had entered since. She
had to find that entrance to gain her freedom. Now that the others
had discovered her absence, they would be alarmed and a search
would be begun. She must get back and reassure them. She must
also send Tom and Jim to find this mysterious stranger.
Flashing on the last faint rays of her flashlight, she saw the wall
down which she had fallen and against it hung a crude rope ladder.
So this was how he entered and left this lower tunnel! With one foot
on the ladder, she slipped her flashlight into her jacket pocket. It had
failed entirely now and she would have to depend on her memory to
lead her to the entrance. It took but a few moments to climb the
ladder and once at the top she pulled it up behind her. That would
keep the ghost in the lower passage until Tom and Jim could come
along and investigate him. There must be some reason why he
“haunted” the cabin with his mysterious knocks.
Swiftly as possible she went along the tunnel and after several
minutes stumbled against the steps leading up to the door.
Chapter VII

LANDSLIDE

“But I can’t understand how he got out!” Gale said again with a
puzzled frown. “I purposely pulled the ladder up behind me to keep
him in there.”
“There must be another way out that’s all,” Tom said.
“He’s gone and now we shall never know who the ghost was,” said
Janet.
Tom and Jim exchanged a fleeting glance that only Gale seemed to
see.
“Well, Gale gives a good imitation of a spook,” was Carol’s
declaration. “Imagine, throwing rocks at the floor to scare us all out
of our well earned sleep.”
“I was only demonstrating how it was done for my own satisfaction,”
Gale laughed.
The nine of them were jogging along on their horses. They had had
their breakfast while they discussed the disappearance of the ghost.
For the man whom Gale had thought imprisoned in the lower tunnel
had gone when Jim and Tom let themselves down on the rope
ladder. They had not explored the tunnel to its full length so they
were not sure, but they surmised that there must be another exit
some place along the passage and it was this that the mysterious
stranger had used. They had all endeavored to go back to sleep, but
their rest was fitful and broken. They had eaten an early breakfast
and now, two hours later, found them picking their way through
cactus and undergrowth to the distant hills.
“Git along little dogie, git along, git along,” Janet sang lustily.
“I wish I had brought some cotton,” Carol commented darkly, “for
my ears,” she added at Janet’s curious glance. “Then I wouldn’t have
to listen to you sing.”
“Oh, you don’t appreciate a good voice when you hear it,” was
Janet’s retort.
“A good voice, I do,” Carol declared, and moved her pony so that
Gale was between her and Janet. “But who ever told you----”
“What? Not another musical person?” Madge demanded as Tom
blew vigorously on his harmonica.
“If riding affects them like that,” Virginia laughed, “it is time we
called a halt. What do you say, Jim?”
“For ten minutes,” Jim nodded.
They fell from their mounts, grateful for the respite. Tom promptly
stretched out on the ground, his hat over his face to shut out the
sun. Jim led the horses to a little stream of water as the girls
stamped the stiffness out of their cramped legs.
“Where’s Jim?” Virginia wanted to know at the end of the allotted
ten minutes for Jim was not in sight. The horses were standing
ready for their riders, but they could not proceed without the guide.
Virginia went over and poked her brother into wakefulness.
“What’s the matter?” he asked drowsily.
“Jim hasn’t come back yet,” Virginia informed him, “and if we don’t
get started, we won’t make our next campsite before dark.”
Tom stretched lazily. “Well, stay here an’ I’ll find him.”
Gale and Virginia mounted their horses and the others did likewise.
“You know, I’m either going to wear the horse out or he is going to
wear me out,” Janet declared with a grimace as she lowered herself
into the saddle. “I’m afraid it is the latter.”
They waited for fully fifteen minutes before either Tom or Jim came
into sight. The horses had caught the impatience of their riders and
were fidgeting to be off.
“We thought you had deserted us for sure!” Virginia declared.
“Where were you?”
To Gale it seemed that the two men had the air of conspirators.
There was a gleam in their eyes that had not been there before. The
minute they came within earshot of the girls they stopped talking
and came on silently.
“Virginia,” Tom said immediately, “we want you to lead the girls to
Bear Rock and have lunch. Wait there for us.”
“But where are you going?” Virginia demanded.
“Jim has found a trail that looks strange so we are going to follow it,”
Tom explained. “But we’ll catch up to you at Bear Rock. You camp
there until we come, understand?”
“No,” Virginia said firmly. “I don’t understand. What is so strange
about this trail? Why can’t we all ride that way?”
“We couldn’t follow the trail with all of you along,” Tom declared. “It
would be obliterated in no time.”
“But, Tom, if we get lost up here we could never find each other
again,” Virginia continued.
“But Miss Virginia, you’ve been to Bear Rock lots of times,” Jim put
in. “Yore Dad would want us to follow this trail, too. It shore looks
mighty strange. You won’t get lost.”
“You don’t know what you might be getting into,” Virginia said. “I
think you should let that trail alone and mind your own business.”
Tom shook his head, tightening his saddle strap.
“We’re goin’ so you might as well save your breath. See you at Bear
Rock,” he added as he and Jim swung their horses about and were
off in a cloud of dust.
The girls stared after them in surprise, then Virginia, with a shrug of
her shoulders, turned her horse and led the way at an abrupt angle
from the road taken by Jim and Tom. Gale undertook to bring up the
rear with the pack horses. As the girls jogged forward, Phyllis rode
directly behind Virginia with Janet and Carol following. Valerie had
dropped behind with Gale.
“Do you suppose that mysterious trail was left by the bank bandits?”
Valerie murmured in a low tone to her friend.
“I shouldn’t be surprised,” Gale answered. “You know, Val, that is
what they are really looking for. I believe that is why Jim has a
definite camping place in mind for each day and doesn’t let us loiter
much along the way. He and Tom must think the rustlers and
robbers are connected.”
Valerie nodded. “Do you think the bandit might have been the man
you saw at the mine last night?”
Gale frowned. “I don’t know. I’ve been thinking about that. It might
have been, but I can’t be sure because I didn’t get a close enough
look at him. He might have been using the cabin as a hiding place.”
“That’s why he tried to scare us away,” added Valerie. “I believe
that’s it!”
“What are you two chattering about?” Janet wanted to know.
“About having broiled rattlesnake for supper,” Valerie retorted. “I’ve
heard it is very good with mustard.”
It was but a short ride to Bear Rock, so named because a huge
boulder so resembled the head of a ferocious grizzly. Once there, the
girls dismounted and gathered wood for a fire. They would eat a
cold luncheon, but insisted on at least having hot coffee to drink.
The horses were tethered and the girls gathered about the fire.
Seated on stones, for the ground was still damp from the heavy
rains of the day before, the girls waited for the two men to join
them. They drank their coffee and had long finished their lunch
before the clatter of hoofs reached them and Jim and Tom rode up.
“We’ll have a new campsite tonight,” Tom said at once. “Jim and I
want to do a little more sleuthing so we might as well go along and
camp when it gets dark, no matter where we are.”
“That’s better than leaving us behind at any rate,” Carol declared.
“I’m rather anxious to get a look at this trail.”
“Just a lot of hoof marks,” Tom answered blandly.
That was all it proved to be and the girls were disappointed. They
didn’t know what they had expected to find, but certainly more than
this. Unexperienced in trail reading they didn’t realize what a wide,
easy-to-read trail had been left. If they had, they might have been
suspicious. Even so, Tom and Jim, western bred and experienced in
trailing both men and animals, should have been suspicious. But
they weren’t.
In the northern region of Arizona are plateaus broken by high
mountains. Between the foothills of a high range was a winding trail
and it was this that the Adventure Girls and their friends followed,
winding in and out through forests thick with pine trees and
cottonwoods, jack rabbits darting across the trail, making the horses
prance and rear, and the girls getting so weary they could hardly
stay in their saddles.
At last Jim called a halt beside a small stream. The sun was sinking
swiftly. Darkness was creeping into the east. When they had pitched
their tents and supper was started, the girls took time out to admire
the scenery of their surroundings. They were camped on the base of
a rugged plateau broken in two by a narrow pass through which
they proposed to ride on the morrow. Overhanging the pass was a
huge boulder, balanced precariously on the edge of the jutting cliff.
“Just one push is all that needs to block up that whole pass,” Tom
declared.
“Let’s hope nobody pushes it tomorrow when we are going through
there,” commented Janet cheerfully.
“Let’s see what is on the other side of the mountain,” proposed Gale
to Valerie.
“All right,” she agreed readily, getting up from her knees where she
had been putting another piece of wood on the fire.
“Or are you too tired?” Gale asked suddenly, remembering that Val
couldn’t keep going as incessantly as the rest of them.
“Of course I’m not too tired for that short walk,” Val said stoutly.
“Come along.”
“When supper is ready give us a halloo,” directed Gale as the two
started out.
“You’re taking awful chances,” Carol declared mischievously, “we
might eat all the supper without you.”
“You had better not!” Gale warned laughingly.
The two walked leisurely, enjoying the glorious hues of the sunset.
In the west the sky was a maze of colors as the last rays of the sun
flashed on the banked clouds. The gurgling of the little stream by
which they walked was the only sound other than that of their
footsteps that they heard. Yet Gale had the uncanny feeling that
eyes were watching them. Once she turned to look back at the
others in camp. They were all busy with something or other. No one
was watching her and Val. Yet that peculiar feeling persisted.
Directly beneath the overhanging boulder they paused to look up at
it. It hung menacingly over them. They took a few steps forward
when something made Gale look up again. Certainly her eyes had
not played a trick on her! The rock had actually wavered. It was
falling!
“Run, Val, run,” she shouted, at the same time grasping her friend’s
arm and pulling her along.
“What in the world----” Valerie began.
“The rock--it’s falling!” Gale panted.
Thereafter she did not need to urge Val to exert speed to get away
from the spot toward which the rock was rushing. The two of them
flung themselves forward while certain destruction hurtled down
almost on them. The boulder crashed into the earth with such force
that it half buried itself. On top of it poured earth that had been
loosened in its descent.
“What if we had been under it?” gasped Val when the girls, at a safe
distance, viewed the wreckage behind them.
“We would look like pancakes now,” Gale said humorously. “With
that landslide, can you tell me how we are going to get out of here
for our supper?”
Valerie looked around. What they had thought was a trail leading
through the mountains was just a trail that led to the basin here, a
valley on all sides of which rose steep hills. Their only means of
entrance and exit had been through the pass, and now that was
effectively stopped.
“I wish we would have waited for supper,” Gale said, attempting to
keep lighthearted.
“You can join us,” said a suave voice behind the girls.
They whirled and were grasped in rough hands.
“Well, two are better ’n none, eh, boss?” a rumbling voice laughed.
“Maybe we couldn’t get ’em all, but these two will do us.”
Both Gale and Valerie struggled, but what was the use? They were
soon subdued, not too gently, and led away, their hands tied behind
their backs, to a cabin, hidden entirely from the trail in a clump of
trees.
Chapter VIII

PRISONERS

“What are you going to do with us?” Gale demanded, summoning as


much courage to her voice as she could.
In the untidy, sparsely furnished room on the first floor of the cabin
the girls faced their abductors, three of the most dangerous, most
crafty looking individuals they had ever seen. It was with a pang of
fear that both Gale and Valerie recognized the leader as one of the
bandits who had robbed the bank in Coxton.
The leader leered at them with a wide grin. “You, my fine young
ladies, are to be our safe ticket across the border.”
“You mean--to hold us as hostages?” Gale asked.
“Call it anything you like,” he retorted. “We’re goin’ to put the
proposition up to your friends. If they don’t agree, you don’t go back
to ’em--that’s all.”
“You wouldn’t dare to harm us!” Gale said staunchly.
He laughed and exchanged glances with the other two men.
“Take ’em upstairs, Mike,” he ordered, and stamped from the cabin.
None too gently one of the other outlaws pushed the girls before
him to where a makeshift ladder led to a loft above the first floor.
They entered through a trap door and it was slammed shut after
them. A rusty bar slithered into place and they were prisoners.
Gale endeavored to stand upright and sat down again abruptly as
her head bumped against a beam in the ceiling.
“Well, we’ve landed ourselves in a fine mess, haven’t we?” she
grumbled.
“What are we going to do, Gale?” Valerie asked.
Gale heard the tremble in Val’s voice and frowned gloomily. It was all
her fault that they were in this predicament. If she hadn’t suggested
the walk they wouldn’t be here now, they would be back with their
friends eating a good supper.
“The first thing seems to be to get loose,” Gale said, keeping her
voice perfectly normal. “Can you get your hands out?”
“No,” Val said after a few moments of futile struggling. “They made a
good job of it.”
“Back up against me,” Gale directed, “and let me see if I can get the
rope off your hands first.”
Valerie did as directed, but it was impossible. Not able to see the
knot and working under such a handicap was too hard. Gale had to
give it up. Below them everything was silent. Had the men really
gone to the camp of the girls’ friends as they said they intended to
do? If so, there must be a way out of the valley other than climbing
over all that newly fallen rock and dirt. The landslide hadn’t blocked
them in then at any rate! If once they got out of this cabin, Gale
knew they would be all right. She had the means in her possession
to guarantee safe conduct of their abductors--or so she thought.
In the wall just above their heads was a window, large enough for
them to squeeze through Gale reflected when she saw it. Large
enough to squeeze through if once they got their hands free and
could open it.
“Gale--even if we get free what will we do?” Valerie asked. “The
window will be too high from the ground to jump. Then, too, those
men will be back soon----”
“If we get free,” Gale gritted through clenched teeth, tugging at the
rope, “things will be simple. I’ve got my revolver in my boot.”
“You haven’t!” Val gasped.
Gale laughed. “Sure I have. I haven’t been without it since my uncle
gave it to me. I intended to save it for rattlesnakes--but now we’ve
got something else to use it on.”
“You wouldn’t actually shoot one of them, would you?” Val asked.
“What would you do?” Gale retorted. “With enough provocation, I
s’pect I would. After all, they’re bandits--and we’re not exactly safe
in their hands.”
“You’re right!” Val said with sudden spirit. “Shoot the whole three--
they need it. I wonder when they will be back?” she added
tremulously.
Gale had gained her feet, keeping her head low this time so as not
to bump it, and standing with her back to the window, her exploring
fingers had encountered the window catch.
“Ouch!” she said suddenly.
“What’s the matter?” Valerie demanded.
“This window catch--it’s as sharp as a knife.” Endeavoring to turn the
catch, her finger had been cut by the edge of the lock. “Sharp as a
knife,” she murmured again under her breath. “Hold everything, Val!”
she cried excitedly.
It was an awkward, uncomfortable position Gale had to assume in
order to be able to work the edge of the rope that bound her hands
together over the catch. It was tiring and so slow, but it was
accomplishing the task. The threads of the rope were being cut
through and in a few moments she would be free. When finally the
rope fell away, her arms were stiff and her wrists sore from where
the rope had cut into the flesh. Then it was only a matter of minutes
until she had Val free, too.
“Listen!” Val said, rubbing her wrists to restore circulation.
The sound of heavy footsteps and the murmur of voices drifted up
to them. The three men reentered the room below and the girls held
their breath. Almost subconsciously Gale secured her tiny revolver
from the top of her boot and grasped it ready in her hand. But the
trap door did not lift. No one came up to see if they were safe.
“What are we going to do now?” Valerie whispered frantically.
Gale went to the window and looked out. A porch had been added
to the cabin and the roof sloped away from the window where she
stood. With a protesting squeak the window swung inward when she
opened it. The girls waited lest the faint noise attract the attention of
their abductors. But the voices continued in their indistinguishable
hum and in a minute Gale was through the window on the roof. She
helped Valerie and the two of them clung to the window sill. Inch by
inch they eased themselves over the short roof to the edge. There,
Gale lay face downward and hung over.
“You’ll fall!” Valerie hissed, holding firmly to her friend’s belt.
“Shshsh,” Gale cautioned. “Are you good at sliding down a pole?
Well, whether you are or not, you’re going to. I’ll go first and catch
you,” she added humorously. “But don’t you fall on top of me!”
Gale restored her revolver to her boot and swung her legs over the
edge. For once in her life, Gale was thoroughly glad for her athletic
training and gymnastic ability. Cautiously she transferred her hold
from the edge of the porch roof to the pole around which her legs
were locked. She lowered herself inch by inch, with some little
damage by splinters, to the ground.
“All right!” she called up to Valerie.
Her friend’s legs appeared over the edge and in another minute Val
had begun her descent of the pole. In a short time she was beside
Gale and the two joined hands to run from the scene. But at the
same moment, the cabin door was thrown open and slammed shut
again behind the leader of the three men. He did not see the girls,
but as they attempted to step back into the shadow of the trees,
Gale stepped on a twig. It cracked as loudly as a pistol report in the
silence.
“Run, Val, toward the pass,” Gale said, her hand on her friend’s arm,
urging her along.
“But you----” Val protested.
“I’m coming,” Gale said. “Go on,” she urged. “I’ll stop him from
following us.”
The leader was coming toward them now, to investigate that
mysterious noise among the trees.
“Who’s there?” he called. “Stop or I’ll shoot!”
But the girls sped off through the trees. A bullet whistled through
the leaves above their heads and abruptly they zigzagged from their
course. They could hear the bandit crashing after them. They
stumbled on, covering the ground as rapidly as they could.
Somewhere ahead was the pass that had been blocked that
afternoon, but surely they could find some way past or over it.
Beyond the pass lay their friends and safety. The thought lent new
vigor to them. Another bullet sped past them.
Gale whirled and fired point blank at the shadow of their pursuer. A
groan was her reward and the chase was effectively stopped. The
shots had summoned the other two men who were thrashing about
in a vain attempt to find the cause of the shooting. By the time they
discovered their companion, the girls were farther away.
Val had reached the blocked pass and was already endeavoring to
climb up and over the landslide when Gale caught up with her. Gale
assisted her chum as much as she could, for she could see that Val
was nearing the end of her endurance. They were forced to rest to
catch their breath several times, and each time they feared that the
three bandits would be on their heels. But silence seemed to have
settled over the valley and the cabin they had left behind. They
heard nothing as they reached the rise of ground and began their
slippery slide down the other side.
Halfway down they met Tom and Jim, who were making an attempt
to climb over the boulder and find the girls, and also to fathom the
mystery of the shots they had heard.
By the time the four arrived at the camp, Tom and Jim were
supporting Valerie. The excitement had buoyed her up, but now that
the suspense was past, Val was utterly worn out.
Chapter IX

ON THE TRAIL

“Did you kill him, I hope?” Janet asked with keen excitement.
Valerie was in her tent asleep while Gale, after a substantial supper,
told the others of what had happened to them. She had come to the
part in their escape when she stopped and fired at the bandit when
Janet voiced her opinion.
Gale shivered. “I hope I didn’t,” she declared. “I wouldn’t care to be
a murderess.”
“I think there is not much danger of that,” Tom reassured her.
“Those fellows are pretty hard to kill.”
“We were all nearly frantic,” Virginia said, a fond arm about Gale’s
shoulders. “First we saw the rock fall and then when you didn’t come
back--we didn’t know what to think or do!”
“That’s something else,” Gale said, “that rock didn’t fall of its own
accord. It was pushed.”
“Are you sure?” Carol demanded.
“I saw the man,” Gale said positively. “Something, I don’t know
what, made me look up just as we were walking under it.”
“That something saved you from being smashed flatter than a
pancake,” Janet said wisely.
“But who would push the rock?” Madge asked wonderingly. “Those
men didn’t actually want to--murder you, did they?”
Gale laughed nervously. “Let’s hope they didn’t; they might try
again.”
“Hereafter none of you go wandering away by yourselves from
camp,” Jim said sternly. “To-morrow Tom and I will go see those
fellows, since they didn’t come to see us,” he added grimly.
“But you----” Virginia was beginning when her voice died away into
silence.
The thunder of hoofs echoed down into the valley to them. All eyes
turned up to where the rim of the mountain was silhouetted against
the moonlit sky. Three black mounted figures were picking their way
slowly across the trail. In a moment they were swallowed up in the
blackness of a forest as they made their way down to the valley
some distance from the Adventure Girls’ camp.
“Three of them,” Tom murmured. “Evidently you didn’t kill that fellow
after all, Gale.”
“And I’m afraid we won’t be able to get a look at them tomorrow,”
Jim added. “We’ll follow their trail of course to see in what direction
they are heading. I think, Virginia, you had better lead the girls back
to the K Bar O. There is too much danger in these hills.”
“Nothing doing,” Janet interrupted, flatly. “We like danger and we
don’t want to go home. If you follow the bandits, so do we!”
“I’m afraid we’re all agreed on that,” Gale nodded.
“So you see it is useless for you to argue,” Virginia added, as Jim
opened his mouth to protest.
“But Dad wouldn’t like it, Virginia,” Tom said with a frown. “Jim and I
are responsible for you girls. If anything happens----”
“Nothing will,” Carol assured him. “We all bear charmed lives. We
shall return to the K Bar O when our trip is over just as we started
out,” she declared.
“But what about Valerie?” Madge put in. “Do you think she can stand
a lot of hard riding?”
Gale grew thoughtful. “She came through tonight with never a
protest. I believe Val can stand a lot more than we give her credit
for.”
Later, lying on her bed of pine boughs beside Phyllis, Gale thought of
Valerie again. It had been strenuous, climbing down from the roof
and later fleeing through the underbrush and over that huge boulder
had been particularly wearying, without considering that they did it
all on top of a day’s riding. Val had borne up marvelously well. True
she had been near collapse at the end, but then she herself had not
had much vitality left and she had always been stronger than
Valerie. Yes sir, Val was in a much better physical condition than
when they had started for the West.
The morning, however, found Valerie not as robust as Gale’s
optimistic thoughts had pictured her. Breaking camp was delayed
until lunch time in order to give Val the benefit of a few more hours
rest. After luncheon, the party saddled and mounted their horses.
After a while, Jim picked up the trail of the outlaws and they
followed it a short distance. But the bandits had evidently suspected
a chase and rode their horses into a stream. From there all trace of
trail was wiped out.
Sunset found them miles from the scene of the girls’ adventure.
Supper was prepared and after it had disappeared they sat about
the campfire telling stories or singing songs. They retired early and
were up with the first rays of the sun.
Day after day they followed the same procedure. Their skins were
getting tanned and their appetites were enormous.
“I never thought I could eat so much,” wailed Janet, after a
particularly hearty meal.
“You’ll look like a baby elephant when we get back home,”
prophesied Carol encouragingly.
They rode like regular westerners now, and every day they
appreciated more and more the beauty of the country through which
they rode. If Jim had planned on showing them the loveliest scenery,
he was running true to plan. The girls had never realized before that
nature, untamed by man, could be so lovely. They never realized
that just to sit and gaze at a sunset could bring such a thrill. In
every way the country was affecting them. Physically they were
healthier than they had ever been. Their mental outlook was
brighter, more cheerful. Here in limitless space, mid tall mountains,
they felt more drawn to one another. Their friendships grew and
flourished.
One day they camped close to the mighty Colorado River that flows
through the Grand Canyon. The cliffs of sandstone and limestone,
almost a mile high, were so rugged and majestic as to fill the girls
with awe. All the colors of the rainbow were in the rocks and under
the influence of the sun and the shadows cast by it, formed pictures
of entrancing beauty, pictures too beautiful to ever be put down on
canvas. Rain and wind had sculptured the cliffs into bewildering and
fantastic forms which added to their brilliant coloring.
“Doesn’t it make you feel tiny?” murmured Janet, scarcely above a
whisper, afraid to disturb the great hush that hung over the Canyon.
“The Canyon was first seen by white men in 1541,” Tom told them.
“The Colorado River where it runs through the Canyon there is three
hundred feet wide, and in times of freshets it’s a mighty torrent.”
“You sound like a traditional guide book,” Janet told him.
“It’s wonderful,” Valerie murmured, voicing the feelings of all of
them.
Another day found the Adventure Girls and their friends examining
the colossal stone tree trunks of the Petrified Forest. Here they
found more to awe and surprise them. Still another day found them
at the rim of the Painted Desert, the desert with its multi-colored
plains alive with somber, purple shadows.
“I’m overwhelmed!” Carol declared. “From now on I shall be a strong
advocate of See America First!”
Valerie had out the little sketching block she always carried with her.
With a strong talent for sketching and limitless subjects on which to
try her skill, Val rode with her pencil and pad in her hands nearly all
day. She wanted to take back home sketches of the spots that
interested her most on this trip.
“I’ll never be able to make it look as beautiful on paper as it really
is,” she sighed. “No one could really hope to.”
“I’d like to have one of the sketches you made of the Canyon the
other day,” Gale said. “I intend to frame it and keep it as a
memento.”
“Isn’t it funny, Gale,” Val mused aloud, “how you never miss
anything until you’ve seen it.”
“You might feel as though you miss something,” Gale agreed, “but
you don’t know what it is.”
“I shall miss all this a lot when we go back East,” Val declared,
looking about at the Arizona sunset. “Everything is so--big out here.
I feel awf’ly small. When I think of the silly things we quarrel over in
school and the things we think we can’t get along without in the city,
it makes me ashamed of myself.”
Gale laughed. “If you lived out here long enough, I’m afraid you
would have a bad inferiority complex.”
“No, but don’t you feel that way?” Val demanded. “Tomorrow we
start for Monument Valley near Kayenta. That’s one hundred and
seventy-five miles from the nearest telephone. Imagine what that
means! Back home we don’t think anything of a telephone because
nearly everybody has one.”
“Yes, and just think, I haven’t had a chocolate soda since I came out
here,” chimed in Janet, coming up behind them. “I hope I shall
survive.”
“You look as though you might pull through,” Valerie laughed.
“Come and get it!” Tom called and there was a concerted rush for
the makeshift supper table.
Day after day they rode through cañons and winding intermittent
gullies, shallow basins, and dry washes. They followed trails through
thick sagebrush and cottonwoods, over dry beds of streams and
sunken deserts, marveling how the dull gray and olive of the
sagebrush and trees mingled. They learned that many of the
mountains were extinct volcanoes and admired the brilliant colored
sandstone and shale formations. Once or twice they ran into heavy
thunderstorms that turned dried-up streams into rushing torrents of
muddy swirling waters.
They explored with keen interest Monument Valley with the spire-like
rock of El Capitan at its head, and its fantastic flat topped pillars
rising thousands of feet into the air. A day’s ride from Kayenta the
riders came upon Betatakin, one of the most interesting, although
least known, of the cliff dwellings, standing silent within its
mammoth cave.
“Just think, hundreds of people lived and died here a thousand years
ago,” Virginia commented.
“I’m glad we don’t live in houses like these,” Janet said, as she
climbed up the worn stone steps to the next level. “I’ve no desire to
climb all these steps every time I want to go home.”
“If you walked in your sleep it was just too bad,” added Carol,
looking back down at the stones over which they had come.
“It gives me an appetite,” Madge complained. “When do we eat?”
“The sooner the better,” put in Phyllis.
For hours the girls prowled around in the dark houses of the cliff
dwellers, taking their time to examine everything of interest. The
next day they resumed their riding, heading south toward the K Bar
O.
During the days Gale and Phyllis had a lot of practice with their
revolvers and now could succeed in coming fairly close to the bull’s
eye every time they tried. Gale, too, was becoming proficient with
her rope. Jim spent hours teaching her and she proved an apt pupil.
Riding with Virginia behind Jim as they swung along the trail, Gale
was looking up at the trees and the blue sky, thinking how she
would hate to leave all this when it came time for the Adventure
Girls to go back East.
“Look out, Jim!” Virginia screamed suddenly.
There was a snarl and a streak of yellow leaped from the low-
hanging limb of a tree. Jim’s horse reared wildly and plunged away
as its rider was dragged from the saddle by the impact of the
cougar’s weight.
For a second none of the riders could do anything but check their
mounts. All the horses threatened to run away and careened wildly,
almost unseating their riders. Meanwhile, Jim was thrashing about
on the ground, struggling for his life while his companions watched
helplessly.
“Quiet, boy,” Gale said, a soothing hand on her trembling pony’s
neck. With her other hand she unfastened her rope.
“Look out, I’m going to shoot,” Tom said, raising his rifle to his
shoulder.
“Don’t!” Carol cried. “You might hit Jim.”
“But the beast is killing him,” Janet said with a shudder. “Somebody
do something!”
Despite Carol’s warning, Tom discharged his gun and succeeded only
in frightening the ponies more. Jim was fighting madly to keep the
sharp claws and teeth away from his face and throat.
Once more Gale spoke to her pony and patted him reassuringly. He
jerked nervously under her hand, but he was by far the quietest one
of the beasts. During the days in the saddle Gale had learned the
tricks and tendencies of her mount and she had instilled a trust in
him for his rider. Now, though he longed to flee from this spot with
its danger, he stood quietly obedient to her voice and touch. In her
hand Gale held her coiled rope. Tom had dismounted and handed
the reins of his horse and of the pack horses to Carol and was
edging nearer to those thrashing figures on the ground. Virginia,
too, had dismounted.
At the first opportune moment, Gale’s rope slithered out and fell over
the two. The loop caught a hind leg of the cougar. Immediately it
tightened and the snapping teeth were diverted from Jim to the rope
about its leg.
“Go it, boy!” Gale urged her horse.
The horse darted forward. Behind her the rope pulled the cougar
clear from Jim. The pony sped down the trail, its rider bent low in
the saddle, the rope dragging the squirming, struggling mountain
lion over the stony ground. Gale did not slow her mount till she was
sure that the animal was dead. Then she turned her horse and
trotted him slowly back to the group.
Tom and Virginia were busy with Jim. The cowboy’s shirt hung in
ribbons, and the flesh of his shoulders and arms was streaming with
blood. He had a long scratch along his cheek, but otherwise he was
safe and sound.
“Never thought that rope trainin’ would come in so handy,” he
grinned at her. “Reckon I owe you a heap for pullin’ that fella offa
me, Miss Gale.”
“Is he dead?” Janet asked tremulously with a glance for the dust
covered thing at the end of Gale’s rope.
“If he isn’t, he ought to be,” Gale replied, dismounting. “Are you hurt
much, Jim?”
The cowboy insisted that they should not stop their day’s ride on his
account. After Tom’s first aid treatment had been administered and
Jim remounted his horse, they started forward again. Tom had cut
the cougar loose from Gale’s rope and pulled him to one side of the
trail.
“That’s what I like about the country out here,” Janet said to no one
in particular. “Always something doing. Any time at all you might
step on a rattlesnake or get jumped on by a ferocious animal. Nice
country!” she declared with a grin.
“Pleasant thoughts you have,” Carol laughed. “It’s no worse than
back home. There we have to dodge street cars and taxi cabs.”
“Give me the taxi cabs,” Madge murmured. “They at least give you a
warning.”
It was late when they stopped for their camp. Riding and excitement
had whetted their appetites and while they ate, Tom and Jim told
them of other experiences each had had with animals in the
surrounding country. Jim took the whole affair as all part of the day,
and refused to declare himself a bit thrilled over it.
“At least we’ll have something to talk about when we get home,”
Phyllis smiled.
“We’ve got a lot to talk about,” Valerie declared. “We’ve met nearly
everything the West can produce, haven’t we?”
“Nearly,” Virginia laughed. “Do you feel like going home now?”
“No!” came unanimously from all the girls.
“Well, whether you like it or not, we are,” Tom declared. “Tomorrow
we get back on K Bar O soil. Two more days and we’ll be at the
ranch house.”
“We’ve got to go home, our supplies are running low,” Virginia
explained.
“Can we go on another trip then?” Carol asked immediately.
“If we have enough time,” Valerie commented. “The days have gone
so quickly. We’ll be going home soon.”
“We’ll refuse to think of that,” Phyllis said firmly. “Let’s hear some
more of your experiences,” she suggested to Jim and Tom.
For another hour while the fire crackled and shadows danced over
the tents and figures around it, Jim entertained them with memories
of the range lands. Valerie and Phyllis retired first. After them went
the other four girls. Gale alone remained beside the fire with her
cousin and the cowboy.
“Tom----” Gale began hesitantly.
“Yes?” Tom encouraged, tossing another log on the fire.
“That trail we passed just before we camped--was it the bandits’?”
she asked.
Tom and Jim exchanged a fleeting glance.
“What made you think of them?” Tom asked.
“Before we started on this trip,” Gale said, “Valerie and I overheard
you and your dad talking about rustlers. We didn’t mean to listen,
but we did. Had that trail today anything to do with them? I thought
you both looked worried when you saw it.”
“We were worried,” Jim admitted. “It was a fresh trail and the same
men who held you prisoner that night in the hills, made that trail.
We thought we had lost them sure, but it doesn’t look that way.”
“What are you going to do?” Gale wanted to know.
“Nothing,” Tom said promptly. “We are going to take you girls safely
back to the K Bar O.”
“The bandits are probably making for the border into Mexico,” Jim
murmured. “The Sheriff and his men will catch ’em.”
Tom laughed. “They haven’t done much catching so far. I’ll bet the
bandits get clean away.”
“Then there is nothing to worry about,” Gale said.
“No, nothing to worry about,” agreed Tom.
When Gale had entered the tent she shared with Valerie and Phyllis,
she went immediately to sleep and did not know that long after she
retired, Tom and Jim talked seriously and long about the possibility
of meeting the rustlers before they reached the ranch safely.
Chapter X

RUSTLERS

“Oh, how I love to get up in the morning,” sang Janet between


yawns as she stumbled from the tent with Carol close behind her.
“Hullo, are we getting company?”
Two cowboys on dust covered, lathered ponies had dashed into the
camp circle and pulled their mounts up short beside the campfire.
Jim who had been on his knees poking at the ashes to stir the
flames to life got up slowly with a wide grin of welcome. Tom joined
the four and Virginia, coming from the tent, greeted them also.
“Let’s get an earful,” Carol proposed. “Evidently they are riders from
the K Bar O.”
“Then ya didn’ see anythin’ of ’em?” one of the new arrivals was
murmuring to Tom.
“Not a thing, Lem,” Tom replied with a serious frown. “How many did
they get?”
“Close to a hundred head, I reckon,” Lem declared viciously.
“By now they are across the border,” Virginia murmured. “Why did
you look for them up here near the hills?”
“A couple of the boys went toward the border,” Lem’s partner
answered. “We found a trail leadin’ up this way.”
“They didn’t pass near here or we would have seen them,” Virginia
said again and her brother and Jim nodded in agreement.
“Then we got to be goin’ farther,” Lem said remounting his pony.
“But can’t you wait and have a bite of breakfast?” Tom wanted to
know.
“Not now, son,” Lem replied. “We’ll eat a cold snack from our saddle
bags. We want to find those birds before the trail is gone.”
“Wish you luck,” Jim sang out as the ponies darted forward.
“Who were they?” Phyllis asked as she, with Gale and Valerie,
appeared.
“Riders from the Lazy K,” Virginia answered. “Rustlers stole close to
a hundred cattle last night. They were following them.”
“But they didn’t bring the cattle up this way, did they?” Carol put in.
“No, but the boys figured some of the riders came this way. I hope
they catch ’em,” Virginia said viciously. “We’re probably due for a raid
tonight.”
Jim and Tom said nothing as they busied themselves getting
breakfast ready. Whatever thoughts they may have had on the
subject, they kept to themselves.
Breakfast was eaten, for the most part, in silence. Even when camp
was struck and they started on their way again, there was not the
usual light-hearted banter and teasing. Each one realized that the
situation at the K Bar O and other ranches was coming to a head.
Rustlers had been busy too long. Now the ranchers were acting.
Instead of going to the ranch for safety from rustlers and bandits, it
seemed that the girls were running into more trouble. Jim led the
way, silent and foreboding. Tom brought up the rear with the pack
horses. He too was silent and grim. It was their attitude that brought
home to the girls just how serious the situation was.
Along about noon Jim’s horse developed a limp that necessitated
their moving more slowly. After deliberation they decided to camp
for the rest of the day and night. Perhaps by the morrow Jim’s horse
would be well again and they could travel at an increased pace. Now
there was an undisguised desire to get back to the ranch house
prevalent with all of them. Things were undoubtedly happening
there and the girls wanted to be in on the excitement. They thought
it high time the ranchers got busy and did something about their
stolen cattle. The authorities had failed to capture the thieves so it
was up to the ranchers themselves.
After camp was made Val took her sketching board and went off by
herself to draw. Gale had not unsaddled her horse and now she
mounted him for a ride.
“Not that there is much to see,” Virginia laughed when Gale started
out. “Just sagebrush, rocks, and trees.”
Gale liked to be alone sometimes and now she did not feel the need
of the companionship of any of her friends. Once in a while the
other girls thought her a little strange when she went off by herself.
But there was nothing strange about her. Gale was the sort of
person who is not dependent upon other people. She could spend a
whole day by herself and not be bored with her own company. She
couldn’t see why some people had to always travel with a crowd,
always have a lot of other people with them. She could enjoy a walk,
a movie, or a ride just as much alone as with others. Of course it
was fun to travel with a group, but she enjoyed a day all to herself
quite as much. When she was alone she could really think.
Gale reined her horse in and looked back at the valley she had just
left. She could see all her friends like moving spots against the dull
gray and olive background. On the other side, the way she faced, a
long flat plain stretched out to the right while on the left was a
forest of cottonwoods and fir trees. There was a narrow trail leading
down from her position on the crest of the hill through the woods
and she urged her horse forward. As she rode, she had to bend low
in the saddle to keep from being slapped in the face by low hanging
branches. Occasionally she saw a rabbit or a squirrel, but for the
most part everything was still.
Her horse was young and frisky and jogged along with light,
prancing step. Gale was enjoying herself hugely with no thought of
the passing of time. Her surroundings were quiet and inspiring and,
as usual with Gale in such circumstances, she was dreaming of a
thousand and one things other than the present. When the girls got
back to Marchton they would start their last year in the Marchton
High School. The next year they started college. As yet the girls had
not firmly decided on the school to which they would go after high
school days. They were concerned now with ideas of what to do and
be when they were finally all through with school. They all firmly
resolved that they wanted careers, but just what those careers were
to be was a little undecided. Of course it was understood that Val
would continue with her art. She was really the only one of them all
that had a talent of any kind to which she could cling. Long and
repeatedly the girls had discussed the subject of careers. What could
they be? Artists? Only Val could do justice to that branch of work.
Actresses then? Well, perhaps Phyllis would go in for the Drama.
Madge, Carol, and Janet were totally at sea, as was Gale herself.
Gale had always thought she might like to be a doctor. But just the
thought of all the years of study and preparation ahead of her was a
little disheartening. She liked the study of medicine and had always
been interested in it. At first she thought of being a nurse, but now
she didn’t like that idea. The thought of being a doctor was much
more intriguing. Doctors led such fascinating lives, she thought. In
her rush of enthusiasm and ardor she didn’t reckon with the long,
tedious hours the doctor devotes to his patients, nor the fact that he
has little free time for himself. Then, too, she would like to be a
sculptor. She liked to model things in clay and she was sure she
could chisel interesting things from marble if given the chance. She
sighed and urged her horse along a little faster. It was really quite a
problem deciding what to be. At any rate, whatever she went into,
she wanted to go into it full of enthusiasm and willingness to work
and do her best. She had no intention of idling her life away. She
wanted to do something, to be somebody, to be proud of her
achievements whatever they might be. She was resolved that she
would forge ahead to success and make a name for herself. After all,
why not? Other people had started out with nothing and made
themselves famous.
A huge drop of water on the back of her neck brought her back
sharply to the problem at hand. Riding along and musing with
herself, she had not noticed the dark clouds that had gathered
overhead from nowhere. Now as her horse came out into an open
clearing, rain began pouring down. She could not hope to get back
to camp before the worst of the storm broke. If this heavy downpour
continued, she would be drenched in a minute. Wildly she looked
about for shelter of some kind. Through the trees to the left she saw
a log cabin, not much of a building, but enough to afford shelter in
the storm. To the rear she found a sheltered hitching post where she
tied her mount and ran back to the main cabin.
One step inside she stopped and glanced around. She had had the
strangest premonition when she stepped over the threshold. It was
as if she had a warning of something dreadful about to happen. The
room--there was only one--was empty of all but its meager
furnishings, a table and two makeshift chairs standing before the
fireplace. A saddle and rifle lay in one corner. On the table were a
few dirty dishes. Someone had been here lately, if they were not
here now. She had seen no horse when she tethered her own, but
there was a saddle and, more ominous still, the rifle. Where was the
owner?
The rain was teeming down outside and she went to the window to
stare out. A regular cloudburst! Tomorrow a lot of the little streams
they had passed would be raging, swirling rivers. She was glad this
cabin had been here or else she would have been drenched. She
smiled as she thought of how her camp mates might be receiving
this sudden rain. They would no doubt be huddled in the waterproof
tents, but nevertheless they would be fuming with disgust. It was no
pleasure camping out when it rained. She looked up at the gray
skies, impatient to be off and away from this cabin that filled her
with that strange, unreasonable fear. Why should she feel fear the
moment she stepped into the place? There was no one here. Not a
thing to frighten her. Yet she was filled with a strange uneasiness.
Evidently her horse had felt it too, for when she had tied him he
whinnied faintly and nudged her arm with mute appeal. She had
thought nothing of it at the time, but now it came back to her with
ominous warning. Animals had keen instinct and the horse had felt a
distrust of this place. She wished heartily it would stop raining so
she could go on. She didn’t want to get wet and she didn’t want to
stay here.
She shook her shoulders impatiently and went over to inspect the
rifle in the corner. Probably she was imagining things. It was the first
time she had let her imagination make her afraid of anything. She
was being silly she told herself again sternly. Most likely this cabin
had been deserted for a long time. But when she picked up the rifle
she knew that wasn’t so. The rifle was clean and recently oiled. Too,
it was loaded. It was the same make rifle as Tom carried in his
saddle sheath and quite without knowing why she took the
cartridges out of the barrel to examine them. At the same moment
she looked up through the window to the trail she had so recently
left for this shelter.
Terror gripped her for a moment. Horsemen were issuing from the
thick growth of trees and there was no disputing the identity of the
first man. It was the bank bandit who had held Val and her prisoners
in that other cabin. She dropped the rifle over the saddle where it
had been and looked about wildly for a means of escape. Were they
close enough to see her if she slipped out of the door? Of course
they were! In the rear wall was a window. She placed a chair
beneath it and a moment later was squeezing through the opening.
Rain or no rain, she preferred to get wet to remaining in the cabin to
receive those men. How had they managed to elude the Sheriff and
his men so long? Were the bank bandits connected with the rustlers
who had been stealing cattle from the K Bar O? Gale made a shrewd
guess that they were.
When she jumped from the window to the wet earth Gale ran
immediately to where her pony was tied and, slipping her arm
through the reins, led him back into the woods to the rear of the
cabin. She was sure the thick growth of trees and brush would shield
them from view and that proved to be the case. The trees overhead
were a little protection from the rain, but even so, when she had
been in the open five minutes she was soaked. She had left her
slicker in the camp and now she wished fervently she had let it
remain rolled behind her saddle. She heard the thunder of hoofs and
sound of voices as the men she had eluded dismounted at the cabin
and entered it. Surprised, she looked down at her hand. She still had
the two shells from the rifle clutched in her fingers. She had
departed in such haste that she didn’t have time to replace them;
indeed, she had not even thought of them. Now she shoved them
deep into her breeches’ pocket and huddled beside her horse.
It would be better to get into the saddle and ride than to stand here
in the rain, but she was sure the sound of her horse’s hoofs would
be clearly audible to those men in the cabin and they would be sure
to investigate. Too, she had an idea. It would be a big help to her
uncle if she could, in some fashion, determine if these were the men
who were stealing cattle from the ranchers. Perhaps, now that she
had stumbled upon their cache, she could spy on them and learn
something of interest to the authorities. It was worth trying. She
would wait until it grew dark and then sneak up and endeavor to
listen to their conversation and to obtain a glimpse of the men within
the cabin.
Her horse whinnied softly and she put an admonishing hand on his
muzzle while her heart raced with apprehension. Suppose one of the
men heard him and came to see---- But they were undoubtedly too
busy and besides, they might think it one of their own horses. Still, it
would be best to be on the safe side. She led her horse farther into
the woods and there tied him to a cottonwood. She was hungry. She
remembered she had had only a light lunch but she remembered,
too, that she had put something in her saddle bag just in case she
wanted an afternoon snack. It came in handy now. She found two
lumps of sugar, also, which the horse promptly snuggled from her
hand.
Another thought came to her and she bent down to her boot. Her
little revolver still nestled in its customary place. She might have use
for it tonight, she reflected. Suppose the men were the rustlers and
suppose she did make sure of that fact. How was she to notify the
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like