SkillAgentSearch skills...

Pgxtutorial

Example of how to build a web service using Go, PostgreSQL, and gRPC

Install / Use

/learn @henvic/Pgxtutorial
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

pgxtutorial

GoDoc Build Status Coverage Status

This is an accompanying repository of the article Back to basics: Writing an application using Go and PostgreSQL by Henrique Vicente. Feel free to open issues to ask any questions or comment on anything.

Environment variables

pgxtutorial uses the following environment variables:

| Environment Variable | Description | | - | - | | PostgreSQL environment variables | Please check https://www.postgresql.org/docs/current/libpq-envars.html | | INTEGRATION_TESTDB | When running go test, database tests will only run if INTEGRATION_TESTDB=true | | OTEL_EXPORTER | When OTEL_EXPORTER=stdout or OTEL_EXPORTER=otel, telemetry is exported |

tl;dr

To play with it install Go on your system. You'll need to connect to a PostgreSQL database. You can check if a connection is working by calling psql.

To run tests:

# Run all tests passing INTEGRATION_TESTDB explicitly
$ INTEGRATION_TESTDB=true go test -v ./...

To run application:

# Create a database
$ psql -c "CREATE DATABASE pgxtutorial;"
# Set the environment variable PGDATABASE
$ export PGDATABASE=pgxtutorial
# Run migrations
$ tern migrate -m ./migrations
# Execute application
$ go run .
2021/11/22 07:21:21 HTTP server listening at localhost:8080
2021/11/22 07:21:21 gRPC server listening at 127.0.0.1:8082

You could also

go install github.com/henvic/pgxtutorial@latest

to just get the pgxtutorial binary.

See also

View on GitHub
GitHub Stars135
CategoryData
Updated1mo ago
Forks9

Languages

Go

Security Score

100/100

Audited on Feb 8, 2026

No findings