Sobes.tech
Junior — Middle

Share details of your most recent professional project or task you have recently tackled.

sobes.tech AI

Answer from AI

In my latest project in Go, I developed a REST API for a task management system. The main goal was to create a reliable and scalable service that allows creating, updating, and deleting tasks, as well as filtering them by status and priority.

For this, I used the standard net/http package for handling requests, and the gorilla/mux library for routing. The data storage was implemented using PostgreSQL with the ORM GORM.

Example of a task creation handler:

func createTaskHandler(w http.ResponseWriter, r *http.Request) {
    var task Task
    err := json.NewDecoder(r.Body).Decode(&task)
    if err != nil {
        http.Error(w, "Invalid input", http.StatusBadRequest)
        return
    }
    if err := db.Create(&task).Error; err != nil {
        http.Error(w, "Failed to create task", http.StatusInternalServerError)
        return
    }
    w.WriteHeader(http.StatusCreated)
    json.NewEncoder(w).Encode(task)
}

I also implemented middleware for logging requests and error handling, which improved the support and debugging of the service.