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.
- Host: GitHub
- URL: https://github.com/rabi-siddique/backend-golang
- Owner: rabi-siddique
- Created: 2024-11-16T08:21:21.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-11-16T10:02:30.000Z (6 months ago)
- Last Synced: 2025-01-30T15:51:44.359Z (4 months ago)
- Topics: golang, golang-backend, golang-http, golang-server
- Language: Go
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
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 |