Simple Go CRUD App with PostgreSQL Database
Field
Type
Reference
ID
int64
json:"id"
Name
string
json:"name"
Location
string
json:"location"
Age
int64
json:"age"
DELETE "/api/deleteuser/{id}"
curl -d '{"name":"paulo", "location":"rio", "age":38}' -H "Content-Type: application/json" -X POST http://localhost:8080/api/newuser
curl -d '{"name":"pedro", "location":"rio", "age":38}' -H "Content-Type: application/json" -X PUT http://localhost:8080/api/user/{id}
curl -H "Content-Type: application/json" -X GET http://localhost:8080/api/user
curl -H "Content-Type: application/json" -X GET http://localhost:8080/api/user/{id}
curl -H "Content-Type: application/json" -X DELETE http://localhost:8080/api/deleteuser/{id}
POSTGRES_URL=postgres://user:pass@<db-host-ip-addr>:5432/databasename?sslmode=disable
git clone https://github.com/paulovigne/goapp.git
cd goapp
docker build -t goapp-crud .
Example of PostgreSQL Database Backend
mkdir -p /postgresql
chown -R 1001:1001 /postgresql
docker run \
--name postgresql \
-e POSTGRESQL_USERNAME=goappuser \
-e POSTGRESQL_PASSWORD=goapppass \
-e POSTGRESQL_DATABASE=goappdb \
-p 5432:5432 \
-v /postgresql:/bitnami/postgresql/data \
bitnami/postgresql:13
docker run \
--name=migrate \
-e POSTGRES_URL=postgres://goappuser:goapppass@<db-host-ip-addr>:5432/goappdb?sslmode=disable \
goapp-crud \
/app/migrate
docker run -d \
--name=goapp \
-p 8080:8080 \
-e POSTGRES_URL=postgres://goappuser:goapppass@<db-host-ip-addr>:5432/goappdb?sslmode=disable \
goapp-crud
git clone https://github.com/paulovigne/goapp.git
cd goapp
kubectl create ns goapp
kubectl -n goapp apply -f kubernetes/