Quick Start
This guide provides the fastest way to get the GoApp application up and running on your local machine.
Running with Docker Compose (Recommended)
The most straightforward method is to use Docker Compose, which will set up the application and a PostgreSQL database instance for you.
Prerequisites
Steps
-
Clone the repository:
git clone https://github.com/naughtygopher/goapp.git cd goapp
-
Start the services: Navigate to the
docker
directory and rundocker-compose up
.
This command will:cd docker docker-compose up --build
- Build the
goapp
Docker image based ondocker/Dockerfile
. - Pull the official
postgres:17
image. - Create a network and start both the application and database containers.
- The database schema is not automatically applied. You'll need to connect to the database on
localhost:5432
and run the scripts from theschemas/
directory as described in the Installation Guide.
- Build the
-
Access the application:
- The main application server will be available at
http://localhost:8080
. - The health check server will be available at
http://localhost:2000
.
- The main application server will be available at
Running Manually
If you prefer to run the application without Docker, you can do so directly using go run
.
Prerequisites
- Complete all steps in the Installation Guide, including setting up the database and environment variables.
Steps
-
Set Environment Variables: Make sure all required environment variables are exported in your current shell session. See the Installation Guide for an example.
-
Run the application: From the root of the project directory, run the following command:
go run main.go inits.go shutdown.go
The sed
command in the original README is for cleaning up JSON log output for better readability in the terminal:
go run main.go inits.go shutdown.go | sed 's/\\n/\n/g;s/\\t/\t/g'
Your First API Call
Once the application is running, you can interact with it using curl
or any API client.
1. Create a User
Send a POST
request to the /users
endpoint to create a new user.
curl -X POST http://localhost:8080/users \
-H "Content-Type: application/json" \
-d '{
"FullName": "John Doe",
"Email": "john.doe@example.com",
"Phone": "123-456-7890",
"ContactAddress": "123 Main St, Anytown, USA"
}'
You should receive a JSON response with the newly created user's data, including a generated ID
.
2. Get User by Email
Send a GET
request to /users/:email
to retrieve the user you just created.
curl http://localhost:8080/users/john.doe@example.com
You should see the full JSON object for John Doe.
3. Check Application Health
You can ping the health check endpoint on port 2000:
curl http://localhost:2000/-/health
This will return a JSON object with the application's status, version, and dependency health.