https://github.com/muthuishere/learning-golang-fiber
https://github.com/muthuishere/learning-golang-fiber
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/muthuishere/learning-golang-fiber
- Owner: muthuishere
- Created: 2023-11-23T05:23:30.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-23T05:26:10.000Z (over 1 year ago)
- Last Synced: 2025-02-06T16:59:05.732Z (3 months ago)
- Language: Go
- Size: 4.87 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
### Learning Golang with Fiber
- [ x ] Printing Hello World
```go
app.Get("/", func(c *fiber.Ctx) error {
return c.SendString("Hello, World!")
})
```- [ x ] Get Path Variables
```go
app.Get("/:name", func(c *fiber.Ctx) error {
return c.SendString("Hello, " + c.Params("name"))
})
```
- How to Convert Data Types from String[strconv](https://pkg.go.dev/strconv)
- How to remove unused Dependencies
```go
go mod tidy
```
- How to have a live reload for Fiber application
- Install air in your system
```bash
go install github.com/cosmtrek/air@latest
```
- add a config file for air
```bash
touch .air.toml
```
- add the following code to the config file
```toml
# .air.toml
root = "."
tmp_dir = "tmp"
[build]
cmd = "go build -o ./tmp/main ."
bin = "./tmp/main"
delay = 1000 # ms
exclude_dir = ["apiscripts", "tmp", "vendor"]
include_ext = ["go", "tpl", "tmpl", "html"]
exclude_regex = ["_test\\.go"]
```
- What should be the status code , if the parameters are invalid
- 400 Bad Request ( I am going with it)- How to Send Invalid Status
```go
c.SendStatus(fiber.StatusBadRequest)
```