Book Image

Hands-On Go Programming

By : Tarik Guney
Book Image

Hands-On Go Programming

By: Tarik Guney

Overview of this book

<p>With its C-like speed, simplicity, and power for a growing number of system-level programming domains, Go has become increasingly popular among programmers. Hands-On Go Programming teaches you the Go programming by solving commonly faced problems with the help of recipes. You will start by installing Go binaries and get familiar with the tools used for developing an application. Once you have understood these tasks, you will be able to manipulate strings and use them in built-in function constructs to create a complex value from two floating-point values. You will discover how to perform an arithmetic operation date and time, along with parsing them from string values. In addition to this, you will cover concurrency in Go, performing various web programming tasks, implementing system programming, reading and writing files, and honing many fundamental Go programming skills such as proper error handling and logging, among others. Whether you are an expert programmer or newbie, this book helps you understand how various answers are programmed in the Go language.</p>
Table of Contents (18 chapters)
Title Page
Copyright and Credits
Packt Upsell
Contributor
Preface
Index

Preface

This book will help you learn Go programming language by solving problems developers commonly face using a recipe approach. You will start by installing Go binaries and become familiar with the tools needed to develop applications. Then you will manipulate strings and use them in built-in constructions and built-in function constructs to create a complex value from two floating-point values. After that, you will learn how to perform arithmetic operations with date and time along with parsing them from string values.

Whether you are an expert programmer or a fresh starter, you will learn how various solutions are programmed in Go, which will take you to the next level in your mastery of Go. These recipes range from concurrency in Go, performing various web programming tasks, doing system programming, reading and writing files, and many fundamental Go programming skills such as proper error handling and doing logging.

Who this book is for

This book caters to software developers who are interested in learning the Go language, and programmers who want to move forward with practical code examples.

What this book covers

Chapter 1Getting Started with Go, addresses the most common problems that new Go developers, as well as people working with other languages, face in their daily programming.

Chapter 2Manipulating String Values, contains some recipes for manipulating string values, such as trimming spaces from beginning and end of a string, extracting sub-strings, replacing parts of a string, escaping characters in a string value, and capitalizing string values.

Chapter 3, Type Conversions, takes you through some practical examples to show you how to convert one type into another effortlessly.

Chapter 4, Date and Time, explains how to work with dates and times in the Go programming language.

 

Chapter 5, Maps and Arrays, covers how to work with maps and arrays in Go.

Chapter 6, Errors and Logging, discusses how to deal with errors and return an error when you need to.

Chapter 7, Files and Directories, provides recipes for working with files and directories in Go.

Chapter 8, Concurrency, explains how to make use of concurrency constructs in the Go language. 

Chapter 9,  System Programming, covers how to process command-line arguments using Go.

Chapter 10Web Programming, contains effective recipes that will involve interactions with the internet, such as downloading a web page, creating our own sample web servers, and handling HTTP requests.

Chapter 11Relational Databases, explains how to read, update, delete, and create data on relational databases with Go.

To get the most out of this book

To follow this book with ease, it is advised that the reader should have sound knowledge of how to develop software. The readers should have basic programming language knowledge, along with an overview of the Go language. You will learn more about the GoLand IDE, which is used throughout the book.

Download the example code files

You can download the example code files for this book from your account at www.packtpub.com. If you purchased this book elsewhere, you can visit 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 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 onscreen 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/Hands-On-Go-Programming. 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!

 

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. Here is an example: "I'm going to use the touch commandto create the main.go file."

A block of code is set as follows:

package main
import "fmt"
func main(){
 fmt.Println(a:"Hello World")
}

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

$go run main.go

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "You can just run it and keep clicking Continue until the installation is complete."

Note

Warnings or important notes appear like this.

Note

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 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 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 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.