Learn Go programming
Learn Go programming
Go Study Notes Version 1.0 dated 16th Aug. 2015
About the Book
About the Contributors
Reviewer
Table of Contents
-
Preface
- Who is the eBook for?
- What will you learn?
- Using code examples
- Errata
- Acknowledgements
- How to contact me?
- Thanks
- How to use this eBook
-
1. Introduction
- 1.1 What is Go?
- 1.2 Go Recent History
- 1.3 Go Authors
- 1.4 Why Go?
-
2. Learn Go programming
- 2.1 Comments
- 2.2 Statements
-
2.3 Identifiers
- 2.3.1 Blank identifier
- 2.3.2 Pre-declared identifiers
- 2.4 Keywords
- 2.5 package
-
2.6 import
- 2.6.1 Aliasing of imports
- 2.6.2 Removing explicit package reference
- 2.7 functions
- 2.8 String literal
-
2.9 Numbers
- 2.9.1 Integers
- 2.9.2 Floating Point Numbers
- 2.9.3 Some default values
-
2.10 Console output
- 2.10.1 Print and Println
- 2.10.2 Formatting using Printf
- 2.11 Console input
- 2.12 Command-line arguments - Args
- 2.13 Solutions
-
3. Variables, Constants, and Types
- 3.1 Variable
-
3.2 Constants
- 3.2.1 Typed and Untyped constants
- 3.3 Named types
- 3.4 Boolean types
-
3.5 Operators
- 3.5.1 Boolean Operators
- 3.5.2 Arithmetic Operators
- 3.5.3 Bitwise Operators
- 3.6 Solutions
-
4. Control Structures
- 4.1 if-else
- 4.2 goto statement
-
4.3 switch
- 4.3.1 fallthrough statement
- 4.4 for loop
- 4.5 Solutions
-
5. Pointers
- 5.1 Solutions
-
6. More on Functions
- 6.1 A function can have multiple return values. Some examples:
- 6.2 A function can take zero or more arguments
- 6.3 Named return values
- 6.4 What’s the idiomatic way to exit a program with some error code?
- 6.5 Variadic Functions
- 6.6 Closures
- 6.7 Recursion
- 6.8 Solutions
-
7. Detailed information
- 7.1 Semicolons
- 7.2 init
- 7.3 Formatting
-
7.4 More on Strings
- 7.4.1 String functions
- 7.5 defer
- 7.6 Using the log package
- 7.7 Using the big package
- 7.8 go vet
- 7.9 golint
- 7.10 goimports
- 7.11 Naming Convention Summary
- 8. Arrays
-
9. Slices
- 9.1 Slice Functions
- 9.2 Slice internals
- 9.3 Passing a slice to a function
-
10. Range
- 10.1 Variadic Functions using range
- 11. Maps
-
12. Structs
- 12.1 What’s the difference between pointer and non-pointer method receivers?
- 12.2 Solutions
-
13. interface
- 13.1 The interface{} type
- 13.2 Solutions
- 14. Error
-
15. io, os and net/http - Getting started
- 15.1 io
- 15.2 os
-
15.3 TCP and net/http
- 15.3.1 Basic Networking
- 15.3.2 Port
- 15.3.3 Internet Addresses
- 15.3.4 net/http
- 16. Random Numbers
-
17. File Handling
- 17.1 Package ioutil
-
17.2 Package os
- 17.2.1 read_file_os1.go
- 17.2.2 read_file_os2.go
- 17.2.3 write_file_os.go
- 17.2.4 read_dir_os.go
-
17.3 Package bufio
- 17.3.1 NewReader
- 17.3.2 Peek
- 17.3.3 NewWriter
- 17.4 Solutions
-
18. JSON and Go
- 18.1 JSON
-
18.2 Package json
- 18.2.1 Encoding
- 18.2.2 Struct tags
- 18.2.3 Decoding
- 18.2.4 Streaming Encoders and Decoders
-
18.3 A Fun, Weather Forecast Go Web App
- 18.3.1 Register for an account at Forecast for Developers
-
19. TCP programming using Go
- 19.1 TCP Sockets
-
19.2 Package net
- 19.2.1 TCP Client
- 19.2.2 A Daytime server
-
20. Unit testing and Benchmarking Go programs
- 20.1 Testing
- 20.2 Benchmarks
-
21. Concurrency
- 21.1 Goroutines
-
21.2 Channels
- 21.2.1 Channel direction
- 21.2.2 Unbuffered channel
-
22. Additional Exercises
- 22.1 Solutions
-
23. Additional Reading
- 23.1 Testable Examples in Go
-
Appendix A
- Downloading Go
-
Install the Go tools
- Test your installation
-
Go Code Organization
- Workspaces
- The GOPATH environment variable
- Package paths
- Editing a Go program
- A Go program
-
Appendix B - Project: redditnews for Baby Gophers
-
Use GitHub
- Create an account
- Set up Git
- Complete Appendix A
- redditnews.go (First Iteration)
-
Use GitHub
-
Appendix C - Build, deploy webapps to cloud
- Complete Appendix A
- A basic Go web app
- Static Sites with Go
- Deploying Go Web Apps to Heroku
-
Cloud Computing Service Levels
- SaaS
- IaaS
- PaaS
- Program webapp_h.go
- Create an account on Heroku
- Install the Heroku Toolbelt
- Create a Procfile
- Use Git
- Install Godep
- Heroku deploy
-
A brief note on Heroku
- Troubleshooting
- Heroku’s Architecture
- Slugs
- License
Other books by this author
The Leanpub 60 Day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.
You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!
So, there's no reason not to click the Add to Cart button, is there?
See full terms...
Earn $8 on a $10 Purchase, and $16 on a $20 Purchase
We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
In fact, authors have earnedover $14 millionwriting, publishing and selling on Leanpub.
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them