CURD using go fiber - gorm - mysql

Overview

GO Fiber - CRUD - GORM - Mysql

Folder Structure

- database          | database config
    |- migration    | migration config
- middleware        | middleware
- public            | public asset
    |- images       | asset image
- route             | route config
- src               | bisnis logic
    |- book         | book => model, response, service
    |- user         | user => model, response, service
- utils             | utilities

Was Implemented

1.  CRUD
2.  Database Connection using GORM Mysql Driver
3.  Database Migration
4.  Middleware
5.  Passing Header Response
6.  Basic Routing
7.  Grouping Routes
8.  Route Static Asset
9.  Handle File Upload and Store to asset directory
10. Handle Delete File from specific directory
11. Get default value from struct (return result only string)
Issues
  • unexpected fault address 0x492610

    unexpected fault address 0x492610

    Fiber v2.22.0 ,GOVERSION="go1.18.3"

    unexpected fault address 0x492610 fatal error: fault [signal SIGSEGV: segmentation violation code=0x2 addr=0x492610 pc=0x442c72]

    goroutine 21 [running]: runtime.throw({0xd23ac1?, 0x0?}) /usr/lib/go/src/runtime/panic.go:992 +0x71 fp=0xc000136140 sp=0xc000136110 pc=0x4674d1 runtime.sigpanic() /usr/lib/go/src/runtime/signal_unix.go:825 +0x305 fp=0xc000136190 sp=0xc000136140 pc=0x47e145 runtime.mapiterinit(0xcb8940?, 0xc00009bd70, 0x492600) /usr/lib/go/src/runtime/map.go:821 +0x72 fp=0xc0001361b8 sp=0xc000136190 pc=0x442c72 reflect.mapiterinit(0xc00009bd70?, 0x0?, 0x0?) /usr/lib/go/src/runtime/map.go:1373 +0x19 fp=0xc0001361e0 sp=0xc0001361b8 pc=0x492619 github.com/gofiber/fiber/v2/internal/go-json/encoder/vm.Run(0xc000282000, {0xc00012e000, 0x0, 0x400}, 0xc00039e1c0) /home/sw/go/pkg/mod/github.com/gofiber/fiber/[email protected]/internal/go-json/encoder/vm/vm.go:425 +0x6902 fp=0xc00013f260 sp=0xc0001361e0 pc=0x8af6a2 github.com/gofiber/fiber/v2/internal/go-json.encodeRunCode(0xc000282000, {0xc00012e000, 0x0, 0x400}, 0x49af25?) /home/sw/go/pkg/mod/github.com/gofiber/fiber/[email protected]/internal/go-json/encode.go:307 +0x272 fp=0xc00013f2e0 sp=0xc00013f260 pc=0x90d572 github.com/gofiber/fiber/v2/internal/go-json.encode(0xc000282000, {0xcb8940, 0xc00009bd70}) /home/sw/go/pkg/mod/github.com/gofiber/fiber/[email protected]/internal/go-json/encode.go:232 +0x4be fp=0xc00013f3b8 sp=0xc00013f2e0 pc=0x90d1be github.com/gofiber/fiber/v2/internal/go-json.marshal({0xcb8940, 0xc00009bd70}, {0x0, 0x0, 0x10000000000?}) /home/sw/go/pkg/mod/github.com/gofiber/fiber/[email protected]/internal/go-json/encode.go:147 +0x177 fp=0xc00013f448 sp=0xc00013f3b8 pc=0x90cbb7 github.com/gofiber/fiber/v2/internal/go-json.MarshalWithOption(...) /home/sw/go/pkg/mod/github.com/gofiber/fiber/[email protected]/internal/go-json/json.go:186 github.com/gofiber/fiber/v2/internal/go-json.Marshal({0xcb8940, 0xc00009bd70}) /home/sw/go/pkg/mod/github.com/gofiber/fiber/[email protected]/internal/go-json/json.go:171 +0x3e fp=0xc00013f4a8 sp=0xc00013f448 pc=0x90d63e github.com/gofiber/fiber/v2.(*Ctx).JSON(0xc0000c82c0, {0xcb8940, 0xc00009bd70}) /home/sw/go/pkg/mod/github.com/gofiber/fiber/[email protected]/ctx.go:650 +0x99 fp=0xc00013f538 sp=0xc00013f4a8 pc=0xaf3779 go-fiber-crud/route.helloWorld(0xc0000cfe40?) /home/sw/dev_go/go-fiber-curd/route/index.route.go:55 +0x105 fp=0xc00013f598 sp=0xc00013f538 pc=0xc5e705 github.com/gofiber/fiber/v2.(*App).next(0xc000102d00, 0xc0000c82c0) /home/sw/go/pkg/mod/github.com/gofiber/fiber/[email protected]/router.go:127 +0x496 fp=0xc00013f6b8 sp=0xc00013f598 pc=0xb03dd6 github.com/gofiber/fiber/v2.(*Ctx).Next(0xc0000c82c0) /home/sw/go/pkg/mod/github.com/gofiber/fiber/[email protected]/ctx.go:747 +0x165 fp=0xc00013f710 sp=0xc00013f6b8 pc=0xaf4ca5 main.main.func1(0xc0000c82c0) /home/sw/dev_go/go-fiber-curd/main.go:33 +0x1c5 fp=0xc00013f760 sp=0xc00013f710 pc=0xc5e905 github.com/gofiber/fiber/v2.(*Ctx).Next(0xc0000c82c0) /home/sw/go/pkg/mod/github.com/gofiber/fiber/[email protected]/ctx.go:744 +0x14d fp=0xc00013f7b8 sp=0xc00013f760 pc=0xaf4c8d github.com/gofiber/fiber/v2/middleware/cors.New.func1(0xc0000c82c0) /home/sw/go/pkg/mod/github.com/gofiber/fiber/[email protected]/middleware/cors/cors.go:141 +0x328 fp=0xc00013f8e8 sp=0xc00013f7b8 pc=0xb0d6a8 github.com/gofiber/fiber/v2.(*App).next(0xc000102d00, 0xc0000c82c0) /home/sw/go/pkg/mod/github.com/gofiber/fiber/[email protected]/router.go:127 +0x496 fp=0xc00013fa08 sp=0xc00013f8e8 pc=0xb03dd6 github.com/gofiber/fiber/v2.(*App).handler(0xc000102d00, 0x10d77b3ad?) /home/sw/go/pkg/mod/github.com/gofiber/fiber/[email protected]/router.go:155 +0x16f fp=0xc00013fa80 sp=0xc00013fa08 pc=0xb0412f github.com/gofiber/fiber/v2.(*App).handler-fm(0x11a6f70?) :1 +0x45 fp=0xc00013fab0 sp=0xc00013fa80 pc=0xb0cb25 github.com/valyala/fasthttp.(*Server).serveConn(0xc0002d8600, {0xead758?, 0xc000010028}) /home/sw/go/pkg/mod/github.com/valyala/[email protected]/server.go:2278 +0x1add fp=0xc00013fe88 sp=0xc00013fab0 pc=0xa5c95d github.com/valyala/fasthttp.(*Server).serveConn-fm({0xead758, 0xc000010028}) :1 +0x4e fp=0xc00013fec8 sp=0xc00013fe88 pc=0xa7516e github.com/valyala/fasthttp.(*workerPool).workerFunc(0xc00038e6e0, 0xc000076000) /home/sw/go/pkg/mod/github.com/valyala/[email protected]/workerpool.go:223 +0xe6 fp=0xc00013ff98 sp=0xc00013fec8 pc=0xa6e946 github.com/valyala/fasthttp.(*workerPool).getCh.func1() /home/sw/go/pkg/mod/github.com/valyala/[email protected]/workerpool.go:195 +0x54 fp=0xc00013ffe0 sp=0xc00013ff98 pc=0xa6e5f4 runtime.goexit() /usr/lib/go/src/runtime/asm_amd64.s:1571 +0x1 fp=0xc00013ffe8 sp=0xc00013ffe0 pc=0x498061 created by github.com/valyala/fasthttp.(*workerPool).getCh /home/sw/go/pkg/mod/github.com/valyala/[email protected]/workerpool.go:194 +0x34a

    error maybe here: index.route.go

    func helloWorld(c *fiber.Ctx) error { ### return c.JSON(fiber.Map{ "hello": "world", "message": "111", }) }

    opened by guoxin718 1
Owner
Muhammad Hizbullah
🔓 web developer
Muhammad Hizbullah
Go-mysql-orm - Golang mysql orm,dedicated to easy use of mysql

golang mysql orm 个人学习项目, 一个易于使用的mysql-orm mapping struct to mysql table golang结构

magacy 141 Aug 12, 2022
Fiber Clean Architecture With GORM

Fiber Clean Architecture With GORM I offer this repository as a proposal for a c

Vinnicyus Gracindo 16 Jul 20, 2022
A simple CRUD API made with Go, Postgres, FIber, Gorm and Docker.

golang-test-api A simple CRUD API made with Go, Postgres, FIber, Gorm and Docker. Cloning the repository To clone the repository run the following com

Wesley Dias 7 Jul 24, 2022
Gorm-sharding - High performance table sharding plugin for Gorm

Gorm Sharding This project has moved to Gorm offical organization: https://githu

Longbridge 67 Jul 8, 2022
100% type-safe ORM for Go (Golang) with code generation and MySQL, PostgreSQL, Sqlite3, SQL Server support. GORM under the hood.

go-queryset 100% type-safe ORM for Go (Golang) with code generation and MySQL, PostgreSQL, Sqlite3, SQL Server support. GORM under the hood. Contents

Denis Isaev 671 Aug 12, 2022
Golang mysql orm, a personal learning project, dedicated to easy use of mysql

golang mysql orm 个人学习项目, 一个易于使用的mysql-orm mapping struct to mysql table golang结构

magacy 1 Dec 30, 2021
A example of a join table using liquibase and gorm

A example of a join table using liquibase and gorm. Additionally the join table's composite key is used as a composite foreign key for another table.

null 1 Feb 4, 2022
RestAPI Starter Template Using Go (Gin + Gorm)

go-gin-gorm-restapi-template Go (Gin + Gorm) を使用した RestAPI 開発のスターターテンプレート RestAPI Starter Template Using Golang (Gin + Gorm) 主要な依存ライブラリ Gin (Web フレームワ

Yuma Ishida 2 Apr 3, 2022
opentracing integration with GORM

gorm-opentracing opentracing support for gorm2. Features Record SQL in span logs. Record Result in span logs. Record Table in span tags. Record Error

null 72 Jul 29, 2022
A code generator base on GORM

GORM/GEN The code generator base on GORM, aims to be developer friendly. Overview CRUD or DIY query method code generation Auto migration from databas

null 1.2k Aug 14, 2022
Converts a database into gorm structs and RESTful api

gen The gen tool produces a CRUD (Create, read, update and delete) REST api project template from a given database. The gen tool will connect to the d

smallnest 1.2k Aug 12, 2022
Scope function for GORM queries provides easy filtering with query parameters

Gin GORM filter Scope function for GORM queries provides easy filtering with query parameters Usage go get github.com/ActiveChooN/gin-gorm-filter Mod

Dmitry Kalinin 4 Jul 16, 2022
A plugin to allow telemetry by NewRelic Go Agent for GORM

GORM NewRelic Telemetry Plugin A plugin to allow telemetry by NewRelic Go Agent for GORM Overview Plugin implementation to add datastore segments on a

Rafael Holanda de Lima 11 May 13, 2022
Gorm firebird driver

gorm-firebird GORM firebird driver import: "github.com/flylink888/gorm-firebird" Example: var products []Product dsn := "SYSDBA:[email protected]/sy

null 6 Apr 21, 2022
OpenTelemetry plugin for GORM v2

gorm-opentelemetry OpenTelemetry plugin for GORM v2 Traces all queries along with the query SQL. Usage Example: // Copyright The OpenTelemetry Authors

ZopSmart 0 Jan 11, 2022
Ormtool - 将数据库表转换为golang的结构体,自定义生成tag,如json,gorm,xorm和简单的db信息

数据库表转换为golang 结构体 1. 获取方式 2. 配置说明 # 保存路径 SavePath: "./models/test.go", # 是

Guolei 1 May 30, 2022
Api-project - Api project with Golang, Gorm, Gorilla-Mux, Postgresql

TECHNOLOGIES GOLANG 1.14 GORM GORILLA-MUX POSTGRESQL API's PATHS For Product Ser

Mustafa Enes Tepe 4 Jul 28, 2022
This library is a complementary library for Gorm (v2) which resolves the first available pool passed to it.

This library is a complementary library for Gorm (v2) which resolves the first available pool passed to it.

Reza Pourmeshki 1 Feb 2, 2022
EZCoin is a control panel for Bitfinex funding, backend is build by Golang, Gin and GORM, frontend is build by angular

EZCoin server is backend for Bitfinex funding, it build by Golang, Gin and GORM.

Dean Lin 0 Feb 7, 2022