This Golang application demonstrates the use of Go's concurrency features, including goroutines, channels, and synchronization, to concurrently fetch and print Pokemon data from the PokeAPI.
The application retrieves a list of Pokemon names and URLs from the PokeAPI, then concurrently fetches additional details (weight, base experience) for each Pokemon using goroutines. The fetched data is printed to the console as it becomes available.
The application relies on the standard library of Go and has no external dependencies.
-
Clone the repository:
git clone https://github.com/iliatalebzade/concurrency-in-go.git cd concurrency-in-go
-
Run the application:
go run main.go
main.go
: Contains the main application logic.README.md
: Documentation for the application.
The application leverages the following concurrency features:
- Goroutines: Utilized to concurrently fetch Pokemon details.
- Channels: Used for communication between goroutines, passing Pokemon names.
- WaitGroup: Ensures that all goroutines finish before closing the source channel.
fetchAndPrintPokemonData
: A function that fetches additional Pokemon details and sends the name to a channel.main
: The main function where the PokeAPI data is retrieved, goroutines are spawned, and the results are printed.
This project is licensed under the MIT License.
Feel free to contribute to this project by opening issues or pull requests.