Goweb

command module
v0.0.0-...-b5db8e0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2024 License: Unlicense Imports: 5 Imported by: 0

README

Goweb

A simple backend development project using Go

Thunder Client configuration available at tool/ directory

Run
  • configure .env file using .env.example structure, source .env
  • docker-compose up -d database
  • docker exec -it db-container-id psql -U a_user -d goweb
  • go run .
setup
  • Router: github.com/gorilla/mux
  • Database: Postgres
  • Database driver for Go: github.com/lib/pq
  • Environment Variable Loader: github.com/joho/Godotenv
database instance
  • postgres database as docker container. (docker-compose up -d service_name)
  • create database tables
  • if database container hosted in cloud, use credentials in .env file (create file). sample .env file is .env.example
models
  • package to store database schema
  • DB schema is mapped as golang structs (exported, json tag included)
middleware
  • bridge between APIs and Database
  • middleware are handlers to handle DB operations (CRUD)
  • add CreatePost handler and logic function to persist post in database
router
  • includes mapping of REST API endpoints to handlers
entrypoint
  • invoke server and expose router endpoints

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL