Instalasi
Prasyarat
Section titled “Prasyarat”Pastikan kamu sudah menginstall:
- Go 1.21 atau yang lebih baru - Download Go
Cek versi Go:
go versionQuick Start
Section titled “Quick Start”1. Download
Section titled “1. Download”Download starter dari GitHub Releases.
Atau clone langsung:
git clone https://github.com/semutdev/goignitercd goigniter/starter2. Install Dependencies
Section titled “2. Install Dependencies”go mod tidy3. Jalankan
Section titled “3. Jalankan”go run main.goBuka http://localhost:8080 - Welcome to GoIgniter!
Struktur Folder
Section titled “Struktur Folder”myapp/├── application/│ ├── controllers/ # Controller kamu│ └── views/ # Template HTML├── public/ # Static files (CSS, JS, images)├── go.mod└── main.go # Entry pointJika kamu familiar dengan CI3:
| CodeIgniter 3 | GoIgniter |
|---|---|
application/controllers/ | application/controllers/ |
application/views/ | application/views/ |
index.php | main.go |
Hello World
Section titled “Hello World”Edit main.go untuk menambah route baru:
app.GET("/hello", func(c *core.Context) error { return c.JSON(200, core.Map{ "message": "Hello World!", })})Restart server dan buka http://localhost:8080/hello
Hot Reload (Opsional)
Section titled “Hot Reload (Opsional)”Untuk auto-restart saat file berubah, gunakan Air:
go install github.com/cosmtrek/air@latestairLanjut ke Routing untuk belajar cara mendefinisikan routes.