Search⌘ K
AI Features

Testing the Finished App Locally

Explore how to test your completed Go and Gin web app locally using Docker and cURL. Understand error handling techniques to prevent crashes, fix bugs through logs, and implement centralized logging for better maintenance and resilience.

We have come a long way since the beginning of this course. There is another thing we can do to make our app even more resilient.

Error handling

Error handling is the process of anticipating all the possible ways our code can fail, catching those errors, and then handling them in a way that doesn't crash the entire application. This process is very straightforward in Go. Instead of figuring out and catching the right kind of exception and nesting the relevant code in it, all we need to do is get the error object returned by a function.

version: '3.0'
services:
    coffeeshop:
        build: .
        ports:
            - "8085:8085"
        env_file:
            - config.env
        volumes:
            - ./:/app/logs
Error handling

In the code widget above:

  • In line 74, we catch the error returned ...