{"id":25271652,"url":"https://github.com/viniciuscestarii/postgres-protocol-go","last_synced_at":"2025-04-06T07:18:05.341Z","repository":{"id":275158517,"uuid":"924662546","full_name":"ViniciusCestarii/postgres-protocol-go","owner":"ViniciusCestarii","description":"🐘 PostgreSQL driver in Go using only the standard library","archived":false,"fork":false,"pushed_at":"2025-02-07T18:19:16.000Z","size":68,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-07T19:23:56.491Z","etag":null,"topics":["postgresql","postgresql-driver","postgresql-protocol"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ViniciusCestarii.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-30T12:29:13.000Z","updated_at":"2025-02-07T18:19:13.000Z","dependencies_parsed_at":"2025-01-31T22:00:32.164Z","dependency_job_id":null,"html_url":"https://github.com/ViniciusCestarii/postgres-protocol-go","commit_stats":null,"previous_names":["viniciuscestarii/postgres-protocol-go"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ViniciusCestarii%2Fpostgres-protocol-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ViniciusCestarii%2Fpostgres-protocol-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ViniciusCestarii%2Fpostgres-protocol-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ViniciusCestarii%2Fpostgres-protocol-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ViniciusCestarii","download_url":"https://codeload.github.com/ViniciusCestarii/postgres-protocol-go/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247445678,"owners_count":20939961,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["postgresql","postgresql-driver","postgresql-protocol"],"created_at":"2025-02-12T12:34:59.623Z","updated_at":"2025-04-06T07:18:05.315Z","avatar_url":"https://github.com/ViniciusCestarii.png","language":"Go","readme":"# Postgres Protocol Go\n\nThis project implements the PostgreSQL wire protocol in Go using only the standard library.\n\n## Usage\n\n```go\nfunc main() {\n\tconnStr := \"postgres://postgres:123456@localhost:5432/postgres\"\n\n\tdriveConfig := models.DriveConfig{Verbose: true,}\n\n\tpgConnection, err := protocol.NewPgConnection(connStr, driveConfig)\n\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\n\tuserToFind := \"postgres\"\n\n\tres, err := pgConnection.Query(\"SELECT * FROM pg_user WHERE usename = $1;\", userToFind)\n\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\tpgConnection.Close()\n\t\treturn\n\t}\n\n\tfmt.Println(\"Postgres user: \", res.Rows)\n\n\tpgConnection.Close()\n}\n```\n\n## Features\n\n- Flexible Connection Handling\n\t- Supports both URL-style connection strings (postgres://user:pass@host:port/db)\n\t- Supports key-value connection strings (`host=localhost port=5432`)\n- SSL/TLS Support\n\t- Automatic SSL/TLS negotiation when `sslmode=require`\n\t- Secure encrypted connections\n- Query Interface\n\t- Simple query protocol support\n\t- Extended query protocol with parameter binding\n\t- Support for parameterized queries using $1, $2 etc.\n- Connection Configuration\n\t- Configurable verbose mode for debugging\n\t- Custom drive configuration options via models.DriveConfig\n- Authentication\n\t- SCRAM-SHA-256\n  \t- md5\n  \t- clear text\n- Clean Resource Management\n\t- Proper connection termination\n\n## Running the Client Implementation example\n\n1. Clone the repository:\n\t```bash\n\tgit clone https://github.com/ViniciusCestarii/postgres-protocol-go.git\n\t```\n\n2. Create environment file:\n\t```bash\n\tcp .env.example .env\n\t```\n\n3. Set the environment variables in the `.env` file.\n\n4. Run the client implementation:\n\t```bash\n\tgo run cmd/client.go\n\t```\n\n## Folder Structure\n\n```bash\npostgres-protocol-go/\n│── cmd/\n│   ├── client.go        # Client implementation example using this driver\n│── internal/\n│   ├── pool/            # Buff writer\n│   ├── protocol/        # PostgreSQL wire protocol handling\n│── pkg/\n│   ├── utils/           # Shared utilities (logging, errors, helpers)\n│   ├── models/          # Data structures for queries, results, etc.\n│── tests/               # Integration and unit tests\n│── go.mod               # Go module file\n│── README.md            # Project documentation\n```\n\n## Testing\n\nTo run the tests, use the following commands:\n\n```bash\ngo test ./tests/...\n```\n\n## Acknowledgements\n\n[Official Protocol Documentation](https://www.postgresql.org/docs/16/protocol.html)\n\n[Message Formats](https://www.postgresql.org/docs/16/protocol-message-formats.html)\n\n[pbkdf2 go implementation](https://cs.opensource.google/go/x/crypto/+/refs/tags/v0.32.0:pbkdf2/pbkdf2.go)\n\n[gp-pg](https://github.com/go-pg/pg)\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fviniciuscestarii%2Fpostgres-protocol-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fviniciuscestarii%2Fpostgres-protocol-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fviniciuscestarii%2Fpostgres-protocol-go/lists"}