使用 Go 语言构建可扩展的 Web 应用程序和 RESTful 服务

5星 · 超过95%的资源 需积分: 9 237 下载量 169 浏览量 更新于2024-07-21 3 收藏 5.11MB PDF 举报
"Web.Development.with.Go.Building.Scalable.Web.Apps.and.RESTful.Services" 本书《Web Development with Go》旨在教会读者如何使用 Go 语言来开发可扩展的 Web 应用程序和 RESTful 服务。Go 语言是一种静态类型、编译型语言,具有快速、可靠和高效的特点,使其非常适合开发各种应用程序,包括系统编程、桌面开发、分布式系统、后端服务、DevOps 和云应用开发等。 本书首先涵盖了 Go 语言的基本概念,然后深入探讨了使用 net/http 包进行 Web 开发的方法。随着每一章的发展,读者将学到如何逐步构建一个真实世界的 Web 系统。 此外,本书还展示了如何将 Go 与其他技术集成,例如使用 MongoDB 作为持久化存储,并提供了一个完整的 REST API 示例,演示了如何使用 Beego 框架构建 Web 应用程序。同时,本书还介绍了如何将 Web 应用程序部署到云平台上,使用 Docker 容器技术来部署 Go Web 应用程序。 本书的主要内容包括: 1. Go 语言基础知识,包括基本语法、数据类型、函数、错误处理等。 2. 使用 net/http 包进行 Web 开发的方法,包括处理 HTTP 请求、响应和会话等。 3. 使用 MongoDB 作为持久化存储的方法,包括数据模型设计、数据查询和数据更新等。 4. 使用 Beego 框架构建 Web 应用程序的方法,包括路由配置、模板引擎和中间件等。 5. 使用 Docker 容器技术部署 Go Web 应用程序的方法,包括容器化、镜像管理和容器编排等。 6. 使用 Google Cloud 平台部署 Web 应用程序的方法,包括云端存储、云端数据库和云端消息队列等。 通过学习本书,读者将获得以下技能和知识: * 掌握 Go 语言的基本概念和语法 * 学会使用 net/http 包进行 Web 开发 * 学会使用 MongoDB 作为持久化存储 * 学会使用 Beego 框架构建 Web 应用程序 * 学会使用 Docker 容器技术部署 Go Web 应用程序 * 学会使用 Google Cloud 平台部署 Web 应用程序 本书旨在教会读者如何使用 Go 语言来开发可扩展的 Web 应用程序和 RESTful 服务,并提供了一个完整的学习路径,帮助读者快速掌握 Go 语言的开发技能。
2017-09-06 上传
Module 1, Learning Go Web Development, starts off with introducing and setting up Go before you move on to produce responsive servers that react to certain web endpoint. You will then implement database connections to acquire data and then present it to our users using different template packages. Later on, you will learn about sessions and cookies to retain information before delving with the basics of microservices. By the end of this module, we will be covering the testing, debugging, and the security aspect. Module 2, Go Programming Blueprints, has a project-based approach where you will be building chat application, adding authentication, and adding your own profile pictures in different ways. You will learn how Go makes it easy to build powerful command-line tools to find domain names before building a highly scalable Twitter polling and vote counting engine powered by NSQ and MongoDB. Later on it covers the functionalities of RESTful Data Web Service API and Google Places API before you move on to build a simple but powerful filesystem backup tool for our code projects. Module 3, Mastering Concurrency in Go, introduces you to Concurrency in Go where you will be understanding the Concurrency model and developing a strategy for designing applications. You will learn to create basic and complex communication channels between our goroutines to manage data not only across single or multithreaded systems but also distributed systems. Later on you will be tackling a real-world problem, that is, being able to develop a high performance web server that can handle a very large volume of live, active traffic. You will then learn how to scale your application and make it capable of being expanded in scope, design, and/ or capacity. It will then focus on when and where to implement concurrent patterns, utilize parallelism, and ensure data consistency. At the end of this module, we will be logging and testing concurrency before we finally look at the best practices on how to implement complicated and advanced techniques offered by Go.
2018-05-25 上传
Chapter 1, Creating Your First Server in Go, explains how to write and interact with HTTP and TCP servers, optimize server responses with GZIP compression, and implement routing and logging in a Go web application. Chapter 2, Working with Templates, Static Files, and HTML Forms, covers how to create HTML templates; serve static resources from the filesystem; create, read, and validate HTML Forms; and implement a simple user authentication for a Go web application. Chapter 3, Working with Sessions, Error Handling, and Caching in Go, explores implementing HTTP sessions, HTTP cookies, error handling, and caching and managing HTTP sessions using Redis, which is required for a web application deployed across multiple data centers. Chapter 4, Writing and Consuming RESTful Web Services in Go, explains how to write RESTful web services, version them, and create AngularJS with TypeScript 2, ReactJS, and VueJS clients to consume them. Chapter 5, Working with SQL and NoSQL Databases, goes through implementing CRUD operations with MySQL and MongoDB databases in a Go web application. Chapter 6, Writing Microservices in Go Using Micro – a Microservice Toolkit, focuses on writing and working with the Protocol Buffers, using a microservice discovery client such as Consul, writing microservices using Go Micro, and interacting with them through command line and web dashboard, along with implementing the API gateway pattern to access the microservices over the HTTP protocol. Chapter 7, Working with WebSocket in Go, looks at writing a WebSocket server and its client as well as writing unit tests and debugging them using the GoLand IDE. Chapter 8, Working with the Go Web Application Framework - Beego, familiarizes setting up the Beego project architecture, writing controllers, views, and filters, implementing caching backed with Redis, and monitoring and deploying the Beego application with Nginx. Chapter 9, Working with Go and Docker, presents writing Docker images, creating Docker containers, user-defined Docker network, working with Docker Registry, and running a Go web application Docker container linked with another Docker container. Chapter 10, Securing a Go Web Application, demonstrates creating server certificates and private keys using OpenSSL, moving an HTTP server to HTTPS, securing RESTful APIs with JSON Web Token (JWT), and preventing cross-site request forgery in Go web applications. Chapter 11, Deploying a Go Web App and Docker Containers to AWS, discusses setting up an EC2 instance, interacting, and running a Go web application and a Go Docker container on it.