This repository contains solutions to exercises from John Arundel's book, "For the Love of Go." It serves as a record of my learning journey and provides potential solutions for others working through the book.
What you'll learn
By reading through this book and completing the exercises, you'll learn:
- How to write tests in Go and how to develop projects guided by tests
- How to manage data in Go using built-in types, user-defined struct types, and collections such as maps and slices
- How to write and test functions, including functions that return multiple results and error values
- How to use objects to model problems in Go, and how to add behaviour to objects using methods
- How to use pointers to write methods that modify objects, and how to use types and validation to make your Go packages easy to use
Getting Started
-
Prerequisites: Ensure you have Go installed and configured on your system. You can find installation instructions on the official Go website: https://golang.org/doc/install
-
Clone this repository:
gh repo clone sebwylleman/for-the-love-of-go
- Navigate to the directory:
cd for-the-love-of-go
- Install dependencies:
Some exercises might require additional packages. In their respective directories, you might find a go.mod
file indicating dependencies. You can install them with:
go mod download
Exercise Structure
Each exercise chapter or section might have its own subdirectory within this repository. Inside these directories, you'll find solution files named descriptively.
Contributing (Optional)
Feel free to add your own solutions, notes, or improvements as you progress through the book. You can fork this repository and submit pull requests with your contributions.
License
This repository is licensed under the MIT License: https://opensource.org/licenses/MIT.
Disclaimer
These solutions are intended to provide a starting point for understanding the exercises. They may not be the most optimal implementations. Refer to the book and official Go documentation for best practices.
Enjoy exploring Go!