Skip to content

kayceenuel/output-and-error-handling

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Output and Error Handling in Go

Error handling and output management in Go can be done by building a client interacting with a weather server. The client fetches weather data from the server, handles errors, and outputs messages to standard output (stdout) and standard error (stderr).

Overview

The project consists of two main components:

  • Client: Fetches weather data from the server, implements retry logic for rate-limited responses (HTTP 429), and properly reports errors.
  • Server: Provided for testing, the server simulates various responses (successful weather data, HTTP 429 with a Retry-After header, and dropped connections).

How to Run

Start the Server

  1. Open a terminal and navigate to the server folder:
    cd server
  2. Run the server:
    go run main.go
    The server listens on port 8080 and simulates various responses (normal, 429, dropped connections).

Run the Client

  1. Open another terminal and navigate to the project root:
    cd output-and-error-handling
  2. Run the client:
    go run main.go
    The client fetches weather data from http://localhost:8080, handles retries for 429 responses, and prints output to stdout (weather data) or stderr (error messages).

Testing

To run the unit tests for the fetcher package:

go test ./fetcher

About

Error handling and output managemen

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages