Hands-On Full Stack Development with Go: Build full stack web applications with Go, React, Gin, and GopherJS 9781789130751, 1789130751

Create a real-world application in Go and explore various frameworks and methodologies for full-stack development Key Fe

9,188 182 18MB

English Pages 324 [309]

Report DMCA / Copyright

DOWNLOAD PDF FILE

Table of contents :
Cover
Title Page
Copyright and Credits
Dedication
About Packt
Contributors
Table of Contents
Preface
Section 1: The Go Language
Chapter 1: Welcome to Full Stack Go
What is full stack development?
What will we build?
The application architecture
The outline of this book
Chapter 2: Building Blocks of the Go Language
Technical requirements
Go's playground
Setting up Go's workspace
Packages, variables, data types, and pointers
Packages
Variables and data types
Pointers
Functions and closures
Functions – the basics
Functions – accessing functions from other packages
Closures
Go data structures
Arrays
Slices
Maps
Struct
Methods
Type embedding
Interfaces
Conditional statements and loops
The if statement
The switch statement
Loops
Panics, recovers, and defers
Summary
Questions
Further reading
Chapter 3: Go Concurrency
What is concurrency?
Goroutines
Go channels
Regular channels
Buffered channels
The select statement
The sync package
The simple mutex
The read-write mutex
Wait groups
Summary
Questions
Further reading
Section 2: The Frontend
Chapter 4: Frontend with React.js
Prerequisites and technical requirements
The GoMusic project
Node.js and the npm
HTML, CSS, and Bootstrap
Project code
The React framework
How to construct React applications
Setting up the project
Installing React
Preparing the new project
JSX and React elements
React components
React application design
Props
State
Initializing the state object
Setting our state
Developer tools
Summary
Questions
Further reading
Chapter 5: Building a Frontend for GoMusic
Prerequisites and technical requirements
Building GoMusic
Main pages
The navigational menu
The Products and Promotions pages
The About page
Modal dialog windows and handling credit cards
The Buy Item modal window outline
Credit card handling with React and Stripe
Creating a child React component to host Stripe elements
Making use of Stripe elements to handle credit card information
Submitting a credit card token to the backend
Creating a parent StripeProvider component
The Sign in and Register modal windows
Handling forms in the React framework
The Sign in page
The Registration form
User pages
The orders page
The user page navigational menu
Putting it all together – routes
Summary
Questions
Further reading
Section 3: Web APIs and Middleware in Go
Chapter 6: RESTful Web APIs in Go with the Gin Framework
Technical requirements
RESTful APIs
Overview
The client-server architecture
URLs
HTTP methods
The Gin framework
Models and the database layer
Models
The database layer interface
Implementing RESTful APIs using the Gin framework
Defining routes
Creating handlers
Getting a full list of available products
Getting a list of promotions
Sign in new users or add new users
Sign out requests
Getting orders for a specific user
Charging a credit card
Putting it all together
Summary
Questions
Further reading
Chapter 7: Advanced Web Go Applications with Gin and React
Technical requirements
The database layer
Relational databases
Setting up
The customer table
The orders table
The products table
ORM
GORM
Implementing the database layer
Middleware
Custom middleware
Security
Certificates and private keys
Establishing trust between the client and the server
Agreeing on, and using an encryption key
Supporting HTTPS in Gin
Password hashing
Implementing password hashing
Comparing the password
Credit card handling
Credit card handling at the backend
Revisiting the frontend code
The app structure
Interactions between the frontend and the backend
Using cookies
Deploying the frontend application
Summary
Questions
Further reading
Chapter 8: Testing and Benchmarking Your Web API
Testing in Go
Mocking
Creating a mock db type
Unit testing in Go
Table-driven development
Benchmarking
Summary
Questions
Further reading
Chapter 9: Introduction to Isomorphic Go with GopherJS
Technical requirements
GopherJS fundamentals
GopherJS types
Object types
Calling JavaScript functions from your Go code
GopherJS commands
Go bindings
Exporting code
Go Methods
Goroutines
GopherJS with React
The project
The project application's architecture
Building the React application in Go
Building a custom component
Summary
Questions
Further reading
Chapter 10: Where to Go from Here?
Cloud-native applications
Microservices
Containers
Serverless applications
Continuous delivery
React Native
What is React Native?
React.js versus React Native
Similarities between React.js and React Native
Differences between React.js and React Native
Expo
Summary
Questions
Other Books You May Enjoy
Index

Hands-On Full Stack Development with Go: Build full stack web applications with Go, React, Gin, and GopherJS
 9781789130751, 1789130751

  • 0 0 0
  • Like this paper and download? You can publish your own PDF file online for free in a few minutes! Sign Up
File loading please wait...
Recommend Papers