Go Web Programming
eBook - ePub

Go Web Programming

Sau Sheong Chang

Condividi libro
  1. 312 pagine
  2. English
  3. ePUB (disponibile sull'app)
  4. Disponibile su iOS e Android
eBook - ePub

Go Web Programming

Sau Sheong Chang

Dettagli del libro
Anteprima del libro
Indice dei contenuti
Citazioni

Informazioni sul libro

Summary Go Web Programming teaches you how to build scalable, high-performance web applications in Go using modern design principles.Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications. About the Technology The Go language handles the demands of scalable, high-performance web applications by providing clean and fast compiled code, garbage collection, a simple concurrency model, and a fantastic standard library. It's perfect for writing microservices or building scalable, maintainable systems. About the Book Go Web Programming teaches you how to build web applications in Go using modern design principles. You'll learn how to implement the dependency injection design pattern for writing test doubles, use concurrency in web applications, and create and consume JSON and XML in web services. Along the way, you'll discover how to minimize your dependence on external frameworks, and you'll pick up valuable productivity techniques for testing and deploying your applications. What's Inside

  • Basics
  • Testing and benchmarking
  • Using concurrency
  • Deploying to standalone servers, PaaS, and Docker
  • Dozens of tips, tricks, and techniques


About the Reader This book assumes you're familiar with Go language basics and the general concepts of web development. About the Author Sau Sheong Chang is Managing Director of Digital Technology at Singapore Power and an active contributor to the Ruby and Go communities. Table of Contents

PART 1 GO AND WEB APPLICATIONS

  • Go and web applications
  • Go ChitChat

PART 2 BASIC WEB APPLICATIONS

  • Handling requests
  • Processing requests
  • Displaying content
  • Storing data

PART 3 BEING REAL

  • Go web services
  • Testing your application
  • Leveraging Go concurrency
  • Deploying Go

Domande frequenti

Come faccio ad annullare l'abbonamento?
È semplicissimo: basta accedere alla sezione Account nelle Impostazioni e cliccare su "Annulla abbonamento". Dopo la cancellazione, l'abbonamento rimarrà attivo per il periodo rimanente già pagato. Per maggiori informazioni, clicca qui
È possibile scaricare libri? Se sì, come?
Al momento è possibile scaricare tramite l'app tutti i nostri libri ePub mobile-friendly. Anche la maggior parte dei nostri PDF è scaricabile e stiamo lavorando per rendere disponibile quanto prima il download di tutti gli altri file. Per maggiori informazioni, clicca qui
Che differenza c'è tra i piani?
Entrambi i piani ti danno accesso illimitato alla libreria e a tutte le funzionalità di Perlego. Le uniche differenze sono il prezzo e il periodo di abbonamento: con il piano annuale risparmierai circa il 30% rispetto a 12 rate con quello mensile.
Cos'è Perlego?
Perlego è un servizio di abbonamento a testi accademici, che ti permette di accedere a un'intera libreria online a un prezzo inferiore rispetto a quello che pagheresti per acquistare un singolo libro al mese. Con oltre 1 milione di testi suddivisi in più di 1.000 categorie, troverai sicuramente ciò che fa per te! Per maggiori informazioni, clicca qui.
Perlego supporta la sintesi vocale?
Cerca l'icona Sintesi vocale nel prossimo libro che leggerai per verificare se è possibile riprodurre l'audio. Questo strumento permette di leggere il testo a voce alta, evidenziandolo man mano che la lettura procede. Puoi aumentare o diminuire la velocità della sintesi vocale, oppure sospendere la riproduzione. Per maggiori informazioni, clicca qui.
Go Web Programming è disponibile online in formato PDF/ePub?
Sì, puoi accedere a Go Web Programming di Sau Sheong Chang in formato PDF e/o ePub, così come ad altri libri molto apprezzati nelle sezioni relative a Informatik e Webservices & APIs. Scopri oltre 1 milione di libri disponibili nel nostro catalogo.

Informazioni

Editore
Manning
Anno
2016
ISBN
9781638353409

Part 1. Go and web applications

Web applications are probably the most widely used type of software application today and if you’re connected to the internet, you would hardly pass a day without using one. Even if you’re mostly on a mobile device, you still are using web applications. Many mobile applications that look like native applications are hybrids that have portions that built on web technologies.
Knowing HTTP is the foundation to learning how to write web applications, so these first two chapters will introduce HTTP. I will also explain why using Go for writing web applications is a good idea. I will jump straight into showing you how to write a simple internet forum using Go and show you a bird’s-eye view of writing a web application.

Chapter 1. Go and web applications

This chapter covers
  • Defining web applications
  • Using Go to write web applications: the advantages
  • Understanding the basics of web application programming
  • Writing the simplest possible web application in Go
Web applications are ubiquitous. Take any application you use on a daily basis, and likely it’s a web application or has a web application variant (this includes mobile apps). Any language that supports software development that interfaces with human beings will inevitably support web application development. One of the first things developers of a new language do is build libraries and frameworks to interact with the internet and the World Wide Web. There are myriad web development tools for the more established languages.
Go is no different. Go is a relatively new programming language created to be simple and efficient for writing back end systems. It has an advanced set of features and focuses on programmer effectiveness and speed. Since its release, Go has gained tremendous popularity as a programming language for writing web applications and *-as-a-Service systems.
In this chapter, you’ll learn why you should use Go for writing web applications and you’ll learn all about web applications.

1.1. Using Go for web applications

So why should you use Go for writing web applications? My guess is, having bought this book, you have an inclination to find out the answer. Of course, as the author of a book that teaches Go web programming, I believe there are strong and compelling reasons to do so. As you continue reading this book, you’ll get a sense of Go’s strengths in web application development and, I hope, agree with me about the usefulness of Go.
Go is a relatively new programming language, with a thriving and growing community. It is well suited for writing server-side programs that are fast. It’s simple and familiar to most programmers who are used to procedural programming, but it also provides features of functional programming. It supports concurrency by default, has a modern packaging system, does garbage collection, and has an extensive and powerful set of built-in standard libraries.
Plenty of good-quality open source libraries are available that can supplement what the standard libraries don’t have, but the standard libraries that come with Go are quite comprehensive and wide-ranging. This book sticks to the standard libraries as much as possible but will occasionally use third-party, open source libraries to show alternative and creative ways the open source community has come up with.
Go is rapidly gaining popularity as a web development language. Many companies, including infrastructure companies like Dropbox and SendGrid, technology-oriented companies such as Square and Hailo, as well as more traditional companies such as BBC and The New York Times, have already started using Go.
Go provides a viable alternative to existing languages and platforms for developing large-scale web applications. Large-scale web applications typically need to be
  • Scalable
  • Modular
  • Maintainable
  • High-performance
Let’s take a look at these attributes in detail.

1.1.1. Scalable web applications and Go

Large-scale web applications should be scalable. This means you should be able to quickly and easily increase the capacity of the application to take on a bigger volume of requests. The application should scale also linearly, meaning you should be able to add more hardware and process a corresponding number of requests.
We can look at scaling in two ways:
  • Vertical scaling, or increasing the amount of CPUs or capacity in a single machine
  • Horizontal scaling, or increasing the number of machines to expand capacity
Go scales well vertically with its excellent support for concurrent programming. A single Go web application with a single OS thread can be scheduled to run hundreds of thousands of goroutines with efficiency and performance.
Just like any other web applications, Go can scale well horizontally as well as by layering a proxy above a number of instances of a Go web app. Go web applications are compiled as static binaries, without any dynamic dependencies, and can be distributed to systems that don’t have Go built in. This allows you to deploy Go web applications easily and consistently.

1.1.2. Modular web applications and Go

Large-scale web applications should be built with components that work interchangeably. This approach allows you to add, remove, or modify features easily and gives you the flexibility to meet the changing needs of the application. It also allows you to lower software development costs by reusing modular components.
Although Go is statically typed, it has an interface mechanism that describes behavior and allows dynamic typing. Functions can take interfaces, which means you can introduce new code into the system and still be able to use existing functions by implementing methods required by that interface. Also, with a function that takes an empty interface, you can put any value as the parameter because all types implement the empty interface. Go implements a number of features usually associated with functional programming, including function types, functions as values, and closures. These features allow you to build more modular code by providing the capability of building functions out of other functions.
Go is also often used to create microservices. In microservice architecture large-scale applications can be created by composing smaller independent services. These services are interchangeable and organized around capabilities (for example, a systems-level service like logging or an application-level service such as billing or risk analysis). By creating multiple small Go services and composing them into a single web application, you enable these capabilities to be swappable and therefore more modular.

1.1.3. Maintainable web applications and Go

Like any large and complex applications, having an easily maintainable codebase is important for large-scale web applications. It’s important because large-scale applications often need to grow and evolve and therefore you need to revisit and change the code regularly. Complex, unwieldy code takes a long time to change and is fraught with risk of something breaking, so it makes sense to keep the source code well organized and maintainable.
Go was designed to encourage good software engineering practices. It has a clean and simple syntax that’s very readable. Go’s package system is flexible and unambiguous, and there’s a good set of tools to enhance the development experience and help programmers to write more readable code. An example is the Go sourc...

Indice dei contenuti