An open API service indexing awesome lists of open source software.

https://github.com/rabi-siddique/backend-golang

This repository is just me learning how to set up a basic server in Golang.
https://github.com/rabi-siddique/backend-golang

golang golang-backend golang-http golang-server

Last synced: about 2 months ago
JSON representation

This repository is just me learning how to set up a basic server in Golang.

Awesome Lists containing this project

README

        

## Go vs Express Comparison

| Feature | Go HTTP Server | Express Server (Node.js) |
| --------------- | ------------------------------------- | --------------------------------------- |
| **Setup** | Minimal, built-in `net/http` package | Requires `express` package installation |
| **Port** | Can specify, e.g., `:8080` | Can specify, e.g., `3000` |
| **Routing** | Uses `http.HandleFunc()` | Uses `app.get()`, `app.post()`, etc. |
| **Dependency** | None, part of Go standard library | Needs `express` package |
| **Performance** | Often faster for simple HTTP handling | Slightly slower but highly flexible |

## JSON Response Handling: Go vs Express

| Feature | Go JSON Response Example | Express JSON Response Example |
| ------------------- | ---------------------------------------- | ------------------------------------------------ |
| **Library/Package** | `encoding/json` | `express` |
| **Response Method** | `json.NewEncoder(w).Encode(response)` | `res.json(data)` |
| **Struct Fields** | Must be exported (capitalized) | Automatically uses object properties |
| **Error Handling** | Manual error checking when encoding JSON | Automatic error handling and response management |