Golang CRUD using database PostgreSQL, adding some fremework like mux and pq.

Overview

Golang CRUD with PostgreSQL

Table of contents 👀

General info

GOPOST or Go-Post is a Golang REST API made to show some indetity for person.

The GOPOST Object 🍵

Properties Description Type
name the identity name String
location location from the identity String
age the age of identity Int64

Routes

Routes HTTP Methods Description
/api/user/ GET Displays all identity
/api/newuser/ POST Creates a new identity
/api/deleteuser/ DELETE Deletes all tea
/api/user/{id} GET Displays a specific tea, given its name
/api/user/{id} PUT Update identitiy Value
/api/user/{id}} DELETE Deletes a specific identity, given its id

Technologies

Project is created with:

  • Golang
  • gorilla/mux
  • lib/pq
  • joho/godotenv
  • ElephantSQL

How I built it

👉 Check out the series here!

Setup

To run this project locally, clone repo and add an .env file in the root:

POSTGRES_URL="Postgres connection string"

Then execute in command prompt:

$ cd go-post
$ go mod tidy
$ go run main.go

API Reference

These are the endpoints available from the app

GET /api/user/

Returns result identity

Response

Show example response

{
  "data": [
    {
     "id":40,
     "name":"hafizh",
     "location": "widodo",
     "age":22,
    }
  ]
}


POST /api/newuser/

Creates a new identity

Request

This request requires body payload, you can find the example below.

Show example payload

{
 "name":"hafizh",
 "location":"kansas",
 "age":12
}

GET /players/:id

Returns a player by id

Response

Show example response

{
  "meta": {
    "code": 200
  },
  "data": {
    "id": "5f6a5c31d7c451c369802c02",
    "name": "John Doe 1",
    "nickname": "Lolo",
    "position": "forward",
    "created_at": "2020-09-22T20:18:57.957Z"
  }
}

GET /players/:id

Returns a player by id

Response

Show example response

{
  "meta": {
    "code": 200
  },
  "data": {
    "id": "5f6a5c31d7c451c369802c02",
    "name": "John Doe 1",
    "nickname": "Lolo",
    "position": "forward",
    "created_at": "2020-09-22T20:18:57.957Z"
  }
}


UPDATE /api/user/:ID

Update value of identity

Response

Show example response

{
    "name": "hafizah",
    "location": "toronto",
    "age": 25,  
}


DELETE /api/user/

Delete all team

DELETE /api/user/:ID

Delete team by id

You might also like...
Repo CRUD - write e read in mongoDB
Repo CRUD - write e read in mongoDB

Meli User - userwrite Este repo é responsável por um cadastro onde teremos somen

[WIP] Basic Echo CRUD template (no pagination)

echo-crud-template [WIP] Basic Echo CRUD template (no pagination) Overview Based on https://github.com/xesina/golang-echo-realworld-example-app. Echo

This repo houses some Golang introductory files, sample codes and implementations

This repo houses some Golang introductory files, sample codes and implementations. I will be updating it as I keep getting a hang of the language.

PolarDB Stack is a DBaaS implementation for PolarDB-for-Postgres, as an operator creates and manages PolarDB/PostgreSQL clusters running in Kubernetes. It provides re-construct, failover swtich-over, scale up/out, high-available capabilities for each clusters.
PolarDB Stack is a DBaaS implementation for PolarDB-for-Postgres, as an operator creates and manages PolarDB/PostgreSQL clusters running in Kubernetes. It provides re-construct, failover swtich-over, scale up/out, high-available capabilities for each clusters.

PolarDB Stack开源版生命周期 1 系统概述 PolarDB是阿里云自研的云原生关系型数据库,采用了基于Shared-Storage的存储计算分离架构。数据库由传统的Share-Nothing,转变成了Shared-Storage架构。由原来的N份计算+N份存储,转变成了N份计算+1份存储

Parallel processing through go routines, copy and delete thousands of key within some minutes

redis-dumper CLI Parallel processing through go routines, copy and delete thousands of key within some minutes copy data by key pattern from one redis

Sensu-go-postgres-metrics - The sensu-go-postgres-metrics is a sensu check that collects PostgreSQL metrics

sensu-go-postgres-metrics Table of Contents Overview Known issues Usage examples

A simple tool to sync your etcd cluster to PostgreSQL in realtime.

etcd-postgresql-syncer A simple tool to sync your etcd cluster to PostgreSQL in realtime. It sets up a watcher on etcd and commits all changes to Post

Pagodasite - Pagoda site written in go uses echo postgresql redis-cli
Pagodasite - Pagoda site written in go uses echo postgresql redis-cli

Pagoda: Rapid, easy full-stack web development starter kit in Go Table of Conten

Simple backup tool for PostgreSQL

pg_back dumps databases from PostgreSQL Description pg_back is a dump tool for PostgreSQL. The goal is to dump all or some databases with globals at o

Owner
Hafizh
I Love be an Open Source Enthusiast and contributing in open source, I hope my knowledge is useful for others
Hafizh
terraform-plugin-mux Example (framework + framework)

Terraform Provider Scaffolding (Terraform Plugin Framework) This template repository is built on the Terraform Plugin Framework. The template reposito

Brian Flad 0 Feb 8, 2022
terraform-plugin-mux Example (upgrade(sdk/v2) + framework)

Terraform Provider Scaffolding (Terraform Plugin Framework) This template repository is built on the Terraform Plugin Framework. The template reposito

Brian Flad 0 Feb 8, 2022
Act is a task runner and supervisor with some great features like act name matching, subacts, etc. We use this in nosebit workspaces.

Act Act is a task runner and supervisor tool written in Go which aims to provide the following features: process supervision in a project level allow

Nosebit 6 May 8, 2022
I'd like to share random apps in the spare times. Thus, I'm going to try learning some concepts of Go and as much as I can I try to clarify each line.

go-samples I'd like to share random apps in the spare times. Thus, I'm going to try learning some concepts of Go and as much as I can I try to clarify

Mert Simsek 1 Mar 16, 2022
Just a playground with some interesting concepts like pipelines aka middleware, handleFuncs, request validations etc. Check it out.

Pipeline a.k.a middleware in Go Just a playground with some interesting concepts like pipelines aka middleware, handleFuncs, request validations etc.

null 0 Dec 9, 2021
Go-Mongodb API - A sample REST API ( CRUD operations ) created using Golang

Go-Mongodb_API This is a sample REST API ( CRUD operations ) created using the G

Aman Sharma 1 May 31, 2022
A plugin for argo which behaves like I'd like

argocd-lovely-plugin An ArgoCD plugin to perform various manipulations in a sensible order to ultimately output YAML for Argo CD to put into your clus

null 120 Dec 27, 2022
crud is a cobra based CLI utility which helps in scaffolding a simple go based micro-service along with build scripts, api documentation, micro-service documentation and k8s deployment manifests

crud crud is a CLI utility which helps in scaffolding a simple go based micro-service along with build scripts, api documentation, micro-service docum

Piyush Jajoo 0 Nov 29, 2021
Golang-samples - Help someone need some practices when learning golang

GO Language Samples This project is to help someone need some practices when lea

Gui Chen 1 Jan 11, 2022
Kubegres is a Kubernetes operator allowing to create a cluster of PostgreSql instances and manage databases replication, failover and backup.

Kubegres is a Kubernetes operator allowing to deploy a cluster of PostgreSql pods with data replication enabled out-of-the box. It brings simplicity w

Reactive Tech Ltd 1.1k Dec 30, 2022