Skip to content

forhadulislam/learn-go-with-examples

Repository files navigation

Learn Go with examples

Learn Golang with real examples. This repo contains example codes for Go beginners. The examples provide a better understanding of using Go features. Here are the list of examples:

1.  Variables
2.  Slices & Maps
3.  Loops
4.  Pointers
5.  Structs
6.  Methods
7.  Error
8.  Interface
9.  Goroutines
10. Channels    
11. Closure    
12. JsonHandler
13. Mutex
14. httptest
15. StringBuilder
16. Files and IO
17. Time and Date
18. OS
19. Atomic counters
20. Worker pools
21. Ticker
22. Timer
23. Reflect
24. Template
25. Advanced template
26. Crypto
27. Callback
28. Patterns
29. Viper
30. Cobra
31. regex
32. Encoding
33. gRPC
34. Race condition
35. gjson
36. Expomential backoff
37. mock with interfaces
38. httpmock
39. Generics (Upcoming)

How to run the examples

You can run the example files if you have Go installed in your system. Here is an example of running examples -

go run 01.Variables/example.go

Tested on: Go version 1.20.5

How to install dependencies

On the root of the project, run the following command -

go mod vendor

How can the examples help

The best way to utilize the examples is to clone the repo and play with the parameters in your local environment. You can also run the examples easily and see the output from whatever IDEs you are using.