Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Go: Design Patterns for Real-World Projects

You're reading from   Go: Design Patterns for Real-World Projects Build production-ready solutions in Go using cutting-edge technology and techniques

Arrow left icon
Product type Course
Published in Jun 2017
Publisher Packt
ISBN-13 9781788390552
Length 1091 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (3):
Arrow left icon
Mario Castro Contreras Mario Castro Contreras
Author Profile Icon Mario Castro Contreras
Mario Castro Contreras
Mat Ryer Mat Ryer
Author Profile Icon Mat Ryer
Mat Ryer
Vladimir Vivien Vladimir Vivien
Author Profile Icon Vladimir Vivien
Vladimir Vivien
Arrow right icon
View More author details
Toc

Table of Contents (38) Chapters Close

Go: Design Patterns for Real-World Projects
Credits
Preface
Bibliography
1. A First Step in Go FREE CHAPTER 2. Go Language Essentials 3. Go Control Flow 4. Data Types 5. Functions in Go 6. Go Packages and Programs 7. Composite Types 8. Methods, Interfaces, and Objects 9. Concurrency 10. Data IO in Go 11. Writing Networked Services 12. Code Testing 13. Ready... Steady... Go! 14. Creational Patterns - Singleton, Builder, Factory, Prototype, and Abstract Factory Design Patterns 15. Structural Patterns - Composite, Adapter, and Bridge Design Patterns 16. Structural Patterns - Proxy, Facade, Decorator, and Flyweight Design Patterns 17. Behavioral Patterns - Strategy, Chain of Responsibility, and Command Design Patterns 18. Behavioral Patterns - Template, Memento, and Interpreter Design Patterns 19. Behavioral Patterns - Visitor, State, Mediator, and Observer Design Patterns 20. Introduction to Gos Concurrency 21. Concurrency Patterns - Barrier, Future, and Pipeline Design Patterns 22. Concurrency Patterns - Workers Pool and Publish/Subscriber Design Patterns 23. Chat Application with Web Sockets 24. Adding User Accounts 25. Three Ways to Implement Profile Pictures 26. Command-Line Tools to Find Domain Names 27. Building Distributed Systems and Working with Flexible Data 28. Exposing Data and Functionality through a RESTful Data Web Service API 29. Random Recommendations Web Service 30. Filesystem Backup 31. Building a Q&A Application for Google App Engine 32. Micro-services in Go with the Go kit Framework 33. Deploying Go Applications Using Docker 1. Good Practices for a Stable Go Environment

Starting with Hello World


This wouldn't be a good book without a Hello World example. Our Hello World example can't be simpler, open your favorite text editor and create a file called main.go within our $GOPATH/src/[your_name]/hello_world with the following content:

package main 
 
func main(){ 
println("Hello World!") 
} 

Save the file. To run our program, open the Terminal window of your operating system:

  • In Linux, go to programs and find a program called Terminal.

  • In Windows, hit Windows + R, type cmd without quotes on the new window and hit Enter.

  • In Mac OS X, hit Command + Space to open a spotlight search, type terminal without quotes. The terminal app must be highlighted so hit Enter.

Once we are in our terminal, navigate to the folder where we have created our main.go file. This should be under your $GOPATH/src/[your_name]/hello_world and execute it:

go run main.go
Hello World!

That's all. The go run [file] command will compile and execute our application but it...

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 €18.99/month. Cancel anytime