# README
Golang-API
This project use packages gorm fiber and use database is MySQL.
Usage
// command run api
go run main.go
Gorm
GORM is an ORM library that handles multiple databases such as MySQL, PostgreSQL, and SQLite.
Installation
go get -u gorm.io/gorm
go get -u gorm.io/driver/mysql
Import
import (
"gorm.io/driver/mysql"
"gorm.io/gorm"
)
Connect Mysql
// username = root, ip = 127.0.0.1:3306, database name = test
dsn := "root:@tcp(127.0.0.1:3306)/test?charset=utf8mb4&parseTime=True&loc=Local"
db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})
Fiber
Fiber is a modern web framework for the Go programming language. It aims to provide a fast, flexible, and efficient way to build web applications and APIs. Fiber is inspired by Express.js, a popular web framework for JavaScript.
Installation
go get github.com/gofiber/fiber/v2
Import
import (
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cors"
)
Config
// Default config
app := fiber.New()
// Custom config
app.Use(cors.New(cors.Config{
AllowCredentials: true,
}))
// set folder public is static
app.Static("/static", "./public")
// set port
app.Listen((":8080"))
# Packages
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author