-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
go-api: Postgres & sqlc #80
Conversation
WalkthroughThis update introduces a comprehensive setup for a Golang API with a PostgreSQL database. It includes a multi-stage Dockerfile, Docker Compose configuration, database migrations, SQL queries, and a REST API with user management capabilities. The project is structured to leverage Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 5
Configuration used: CodeRabbit UI
Files ignored due to path filters (4)
examples/golang-api-with-postgres-and-sqlc/compose.yml
is excluded by:!**/*.yml
examples/golang-api-with-postgres-and-sqlc/go.mod
is excluded by:!**/*.mod
examples/golang-api-with-postgres-and-sqlc/go.sum
is excluded by:!**/*.sum
examples/golang-api-with-postgres-and-sqlc/sqlc.yaml
is excluded by:!**/*.yaml
Files selected for processing (8)
- examples/golang-api-with-postgres-and-sqlc/.gitignore (1 hunks)
- examples/golang-api-with-postgres-and-sqlc/Dockerfile (1 hunks)
- examples/golang-api-with-postgres-and-sqlc/README.md (1 hunks)
- examples/golang-api-with-postgres-and-sqlc/db/database.go (1 hunks)
- examples/golang-api-with-postgres-and-sqlc/handlers/handlers.go (1 hunks)
- examples/golang-api-with-postgres-and-sqlc/main.go (1 hunks)
- examples/golang-api-with-postgres-and-sqlc/query.sql (1 hunks)
- examples/golang-api-with-postgres-and-sqlc/schema.sql (1 hunks)
Files skipped from review due to trivial changes (2)
- examples/golang-api-with-postgres-and-sqlc/.gitignore
- examples/golang-api-with-postgres-and-sqlc/README.md
Additional comments: 1
examples/golang-api-with-postgres-and-sqlc/query.sql (1)
- 1-14: The SQL queries for user operations are correctly parameterized, which helps prevent SQL injection. Good job following best practices here. Ensure that the
username
column is indexed to optimize the performance of theListUsers
query, as mentioned in the review ofschema.sql
.
examples/golang-api-with-postgres-and-sqlc/handlers/handlers.go
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files ignored due to path filters (2)
examples/golang-api-with-postgres-and-sqlc/compose.yml
is excluded by:!**/*.yml
examples/golang-api-with-postgres-and-sqlc/sqlc.yaml
is excluded by:!**/*.yaml
Files selected for processing (2)
- examples/golang-api-with-postgres-and-sqlc/README.md (1 hunks)
- examples/golang-api-with-postgres-and-sqlc/schema.sql (1 hunks)
Files skipped from review as they are similar to previous changes (2)
- examples/golang-api-with-postgres-and-sqlc/README.md
- examples/golang-api-with-postgres-and-sqlc/schema.sql
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 8
Out of diff range and nitpick comments (1)
examples/golang-api-with-postgres-and-sqlc/README.md (1)
14-19
: Correct typographical error in the prerequisites section.There's a repeated word "Docker" in the prerequisites section. Consider correcting this to improve the clarity of the documentation.
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (2)
examples/golang-api-with-postgres-and-sqlc/go.mod
is excluded by!**/*.mod
examples/golang-api-with-postgres-and-sqlc/go.sum
is excluded by!**/*.sum
Files selected for processing (17)
- examples/golang-api-with-postgres-and-sqlc/.gitignore (1 hunks)
- examples/golang-api-with-postgres-and-sqlc/Dockerfile (1 hunks)
- examples/golang-api-with-postgres-and-sqlc/README.md (1 hunks)
- examples/golang-api-with-postgres-and-sqlc/compose.yml (1 hunks)
- examples/golang-api-with-postgres-and-sqlc/db/database.go (1 hunks)
- examples/golang-api-with-postgres-and-sqlc/db/migrations/schema.sql (1 hunks)
- examples/golang-api-with-postgres-and-sqlc/db/query/user.sql (1 hunks)
- examples/golang-api-with-postgres-and-sqlc/db/sqlc/db.go (1 hunks)
- examples/golang-api-with-postgres-and-sqlc/db/sqlc/models.go (1 hunks)
- examples/golang-api-with-postgres-and-sqlc/db/sqlc/querier.go (1 hunks)
- examples/golang-api-with-postgres-and-sqlc/db/sqlc/user.sql.go (1 hunks)
- examples/golang-api-with-postgres-and-sqlc/handler/handler.go (1 hunks)
- examples/golang-api-with-postgres-and-sqlc/main.go (1 hunks)
- examples/golang-api-with-postgres-and-sqlc/model/model.go (1 hunks)
- examples/golang-api-with-postgres-and-sqlc/repository/repository.go (1 hunks)
- examples/golang-api-with-postgres-and-sqlc/service/service.go (1 hunks)
- examples/golang-api-with-postgres-and-sqlc/sqlc.yaml (1 hunks)
Files skipped from review due to trivial changes (7)
- examples/golang-api-with-postgres-and-sqlc/.gitignore
- examples/golang-api-with-postgres-and-sqlc/Dockerfile
- examples/golang-api-with-postgres-and-sqlc/compose.yml
- examples/golang-api-with-postgres-and-sqlc/db/migrations/schema.sql
- examples/golang-api-with-postgres-and-sqlc/db/sqlc/querier.go
- examples/golang-api-with-postgres-and-sqlc/model/model.go
- examples/golang-api-with-postgres-and-sqlc/service/service.go
Additional Context Used
LanguageTool (1)
examples/golang-api-with-postgres-and-sqlc/README.md (1)
Near line 16: Possible typo: you repeated a word
Context: ...erall performance. ## Prerequisites - Docker - Docker Compose -sqlc
## Setup 1. **Clone ...
Additional comments not posted (5)
examples/golang-api-with-postgres-and-sqlc/sqlc.yaml (1)
1-20
: Configuration settings insqlc.yaml
are correctly set up.The SQLC configuration is appropriately set for PostgreSQL with
pgx/v5
, and the settings likeemit_interface
andemit_empty_slices
are beneficial for the generated code structure.examples/golang-api-with-postgres-and-sqlc/db/sqlc/db.go (1)
14-32
: Database transaction setup indb.go
is well-implemented.The
DBTX
interface andQueries
struct are correctly set up for handling database transactions usingpgx
, and the use of context in these operations is a best practice.examples/golang-api-with-postgres-and-sqlc/db/sqlc/user.sql.go (2)
46-74
: The implementation ofGetUser
is correct and follows best practices.
76-116
: The implementation ofListUsers
is correct and efficiently handles database rows and errors.examples/golang-api-with-postgres-and-sqlc/handler/handler.go (1)
59-79
: The implementation ofGetUser
correctly handles user ID parsing and error responses.
examples/golang-api-with-postgres-and-sqlc/repository/repository.go
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- examples/golang-api-with-postgres-and-sqlc/.gitignore (1 hunks)
- examples/golang-api-with-postgres-and-sqlc/Dockerfile (1 hunks)
Files skipped from review as they are similar to previous changes (2)
- examples/golang-api-with-postgres-and-sqlc/.gitignore
- examples/golang-api-with-postgres-and-sqlc/Dockerfile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- examples/golang-api-with-postgres-and-sqlc/handler/handler.go (1 hunks)
- examples/golang-api-with-postgres-and-sqlc/repository/repository.go (1 hunks)
- examples/golang-api-with-postgres-and-sqlc/service/service.go (1 hunks)
Files skipped from review as they are similar to previous changes (3)
- examples/golang-api-with-postgres-and-sqlc/handler/handler.go
- examples/golang-api-with-postgres-and-sqlc/repository/repository.go
- examples/golang-api-with-postgres-and-sqlc/service/service.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- examples/golang-api-with-postgres-and-sqlc/.sqlfluff (1 hunks)
Files skipped from review due to trivial changes (1)
- examples/golang-api-with-postgres-and-sqlc/.sqlfluff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- examples/golang-api-with-postgres-and-sqlc/db/database.go (1 hunks)
- examples/golang-api-with-postgres-and-sqlc/main.go (1 hunks)
Files skipped from review as they are similar to previous changes (2)
- examples/golang-api-with-postgres-and-sqlc/db/database.go
- examples/golang-api-with-postgres-and-sqlc/main.go
What's this PR do?
Go API using PostgresQL as DB and sqlc as a query generator.
Summary by CodeRabbit
New Features
Documentation
Chores
.gitignore
to include patterns for ignoring binaries, test outputs, and other development artifacts.sqlfluff
.