Book Image

Go Systems Programming

Book Image

Go Systems Programming

Overview of this book

Go is the new systems programming language for Linux and Unix systems. It is also the language in which some of the most prominent cloud-level systems have been written, such as Docker. Where C programmers used to rule, Go programmers are in demand to write highly optimized systems programming code. Created by some of the original designers of C and Unix, Go expands the systems programmers toolkit and adds a mature, clear programming language. Traditional system applications become easier to write since pointers are not relevant and garbage collection has taken away the most problematic area for low-level systems code: memory management. This book opens up the world of high-performance Unix system applications to the beginning Go programmer. It does not get stuck on single systems or even system types, but tries to expand the original teachings from Unix system level programming to all types of servers, the cloud, and the web.
Table of Contents (13 chapters)

Reading and writing data records

This section will teach you how to deal with writing and reading data records. What differentiates a record from other kinds of text data is that a record has a given structure with a specific number of fields: think of it as a row from a table in a relational database. Actually, records can be very useful for storing data in tables in case you want to develop your own database server in Go!

The Go code of records.go will save data in the CSV format and will be presented in four parts. The first part contains the following Go code:

package main 
 
import ( 
   "encoding/csv" 
   "fmt" 
   "os" 
) 

So, this is where you have to declare that you are going to read or write data in the CSV format. The second part is the following:

func main() { 
   if len(os.Args) != 2 { 
         fmt.Println("Need just one filename...