Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Hands-On Full Stack Development with Go

You're reading from   Hands-On Full Stack Development with Go Build full stack web applications with Go, React, Gin, and GopherJS

Arrow left icon
Product type Paperback
Published in Mar 2019
Publisher Packt
ISBN-13 9781789130751
Length 324 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Mina Andrawos Mina Andrawos
Author Profile Icon Mina Andrawos
Mina Andrawos
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Preface 1. Section 1: The Go Language
2. Welcome to Full Stack Go FREE CHAPTER 3. Building Blocks of the Go Language 4. Go Concurrency 5. Section 2: The Frontend
6. Frontend with React.js 7. Building a Frontend for GoMusic 8. Section 3: Web APIs and Middleware in Go
9. RESTful Web APIs in Go with the Gin Framework 10. Advanced Web Go Applications with Gin and React 11. Testing and Benchmarking Your Web API 12. Introduction to Isomorphic Go with GopherJS 13. Where to Go from Here? 14. Other Books You May Enjoy

Interfaces

After covering methods, we must cover interfaces, which make use of methods to produce efficient and scalable code in the Go language.

An interface can be very simply described as a Go type that hosts a collection of methods.

Here is a simple example:

type MyInterface interface{
GetName()string
GetAge()int
}

The preceding interface defines two methods—GetName() and GetAge().

Earlier, we attached two methods with the same signature to a type called Person:

type Person struct{
name string
age int
}
func (p Person) GetName()string{
return p.name
}
func (p Person) GetAge()int{
return p.age
}

In Go, an interface can be implemented by other types, like Go structs. When a Go type implements an interface, a value of the interface type can then hold that Go type data. We'll see what that means very shortly.

A very special feature in Go is the fact that for...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image