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

Reading data from databases


Let's begin with learning how to read data from SQL databases. Before we begin, we will have to create a database called personal.db. We are going to use a DB browser for SQLite that allows us to create new SQLite databases, edit them, add new records, and so on. You can find more information about the tool and download it from http://sqlitebrowser.org/. It is a free tool and it works with Windows, macOS, and Linux. Let's begin with an example. Check out the following screenshot:

Here, we have just one table, called profile. Working on this table will be sufficient for us to learn how to interact with the SQLite database, and then you can use the same techniques to interact with MySQL or SQL Server. If you check the screenshot, you can see that we have three records and four columns: ProfileId, FirstName, LastName, and Age. The FirstName and LastName columns are a string, or text, the Age column is a number, and the ProfileId is our primary key; it isalso an integer...