Skip to content

Repository files navigation

Creatopia - Golang API

Prerequisites

  • Go 1.25.1+
  • PostgreSQL 12+
  • Git
  • [Optional] Air (for development hot reload)

Environment Variables

Disarankan membuat environment berbeda untuk development dan production.

Development

  1. Buat file .env / copy file .env.example di root project dengan isi contoh berikut:
DB_HOST=localhost
DB_PORT=5432
DB_USER=mariousers
DB_PASS=mariopassword 
DB_NAME=testing

APP_PORT=3001
APP_ENV=development
  1. Install dependencies:
go mod tidy
  1. Jalankan aplikasi:
  • Dengan hot reload (opsional, bila menggunakan Air):
air
  • Atau jalankan biasa:
go run main.go

Pastikan environment dari .env.dev sudah ter-load (mis. gunakan tool seperti direnv, atau export variabel secara manual sebelum menjalankan aplikasi).

Production

  1. Siapkan environment. Opsi yang direkomendasikan adalah set langsung di server (bukan file). Jika tetap ingin file, buat .env dengan contoh berikut:
DB_HOST=localhost
DB_PORT=5432
DB_USER=mariousers
DB_PASS=mariopassword
DB_NAME=testing

APP_PORT=1234
APP_ENV=production

Tip: Demi keamanan, hindari commit .env ke repository publik.

  1. Build binary release:
go build -o bin/myapp ./cmd/http/main.go
  1. Jalankan binary (pastikan environment production sudah di-set):
./bin/myapp

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages