Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Bug report
description: Something in GSDB doesn't work as expected
labels: ["bug"]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to report a bug. Please **do not** report security issues here; see SECURITY.md.
- type: textarea
id: what-happened
attributes:
label: What happened?
description: What did you expect, and what happened instead? Include any error messages.
validations:
required: true
- type: textarea
id: repro
attributes:
label: Minimal reproduction
description: The struct definition (with `db` tags), the table schema, and the GSDB calls that trigger the problem.
render: go
validations:
required: true
- type: textarea
id: sql
attributes:
label: Generated SQL / logs
description: Output with `gsdb.ShowSQL = true`, if relevant. Remove any secrets.
render: text
- type: input
id: version
attributes:
label: GSDB version
placeholder: v0.0.14
validations:
required: true
- type: dropdown
id: database
attributes:
label: Database
options:
- MySQL
- MariaDB
- SQLite
- Other
validations:
required: true
- type: input
id: db-version
attributes:
label: Database version
placeholder: MySQL 8.4 / SQLite 3.46
- type: input
id: go-version
attributes:
label: Go version and OS
placeholder: go1.26.0 linux/amd64
validations:
required: true
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: true
contact_links:
- name: Report a security vulnerability
url: https://github.com/SpaceTent/GoStructDB/security/advisories/new
about: Please report security issues privately, not as public issues. See SECURITY.md.
27 changes: 27 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Feature request
description: Suggest an idea or improvement for GSDB
labels: ["enhancement"]
body:
- type: textarea
id: problem
attributes:
label: What problem are you trying to solve?
description: Describe the use case. GSDB deliberately keeps SQL visible, so explain where the current API gets in the way.
validations:
required: true
- type: textarea
id: proposal
attributes:
label: Proposed solution
description: What would you like GSDB to do? An example of the API you'd like to write helps a lot.
render: go
- type: textarea
id: alternatives
attributes:
label: Alternatives considered
- type: checkboxes
id: contribute
attributes:
label: Contribution
options:
- label: I'd be willing to open a pull request for this.
25 changes: 25 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## What does this PR do?

<!-- A short description of the change and why it is needed. -->

Fixes #<!-- issue number, if any -->

## Type of change

- [ ] Bug fix
- [ ] New feature
- [ ] Documentation
- [ ] Refactor / chore

## Checklist

- [ ] `go build ./...` passes
- [ ] `go vet ./...` passes
- [ ] `go test ./...` passes
- [ ] Code is formatted (`gofmt -s -w .` / `goimports -w .`)
- [ ] Docs (README / docs/) updated if behaviour changed
- [ ] CHANGELOG.md updated under **Unreleased** for user-facing changes

## How was this tested?

<!-- Commands you ran, environments you tried, screenshots for UI changes. -->
60 changes: 60 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Changelog

All notable changes to this project are documented here.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this
project uses [Semantic Versioning](https://semver.org/) tags (pre-1.0, so minor API changes
can happen in any `v0.0.x` release). Earlier entries were reconstructed from the git history
and GitHub releases.

## [Unreleased]

### Added
- LICENSE (MIT), CONTRIBUTING, CODE_OF_CONDUCT, SECURITY, issue and PR templates.
- Expanded README, `docs/getting-started.md`, `docs/architecture.md` and `examples/README.md`.

## [v0.0.14] - 2026-09-08

### Changed
- Connection pool size is now configurable through `gsdb.MaxOpenConns` and
`gsdb.MaxIdleConns` (default 50 each, previously fixed at 25).

## [v0.0.13] - 2026-03-06

### Added
- `Save` example for `readdefault=null` dates (`examples/Save-DateDefault.go`).

### Changed
- Examples now run against SQLite (`NewSQLite3`) by default.

## [v0.0.12] - 2026-03-04

### Added
- `readdefault=null` for `time.Time` fields: zero times are written as SQL `NULL` on
insert/update, and `NULL` is read back as the zero time.

## [v0.0.11] - 2026-02-25

### Added
- Tests for `Execute`, `Record` insert/update and `QueryStruct`.

### Changed
- README re-worded and typos fixed.
- Dependency updates.

## [v0.0.7] - 2025-05-14

### Added
- First GitHub release: `New`, `NewSQLite3`, `Execute`, `Query`, `QueryStruct`,
`QuerySingleStruct`, `Insert`, `Update`, `Save`, `Record`/`Field` helpers, counters,
and a GitHub Actions release workflow.

Tags `v0.0.0`–`v0.0.6` and `v0.0.8`–`v0.0.10` exist in git but have no GitHub release
or separate notes; their changes are folded into the nearest release above.

[Unreleased]: https://github.com/SpaceTent/GoStructDB/compare/v0.0.14...HEAD
[v0.0.14]: https://github.com/SpaceTent/GoStructDB/compare/v0.0.13...v0.0.14
[v0.0.13]: https://github.com/SpaceTent/GoStructDB/compare/v0.0.12...v0.0.13
[v0.0.12]: https://github.com/SpaceTent/GoStructDB/compare/v0.0.11...v0.0.12
[v0.0.11]: https://github.com/SpaceTent/GoStructDB/compare/v0.0.7...v0.0.11
[v0.0.7]: https://github.com/SpaceTent/GoStructDB/releases/tag/v0.0.7
83 changes: 83 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
* Focusing on what is best not just for us as individuals, but for the overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.

Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at **mark@ackroyd.net**. All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series of actions.

**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within the community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1, available at [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].

Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder][Mozilla CoC].

For answers to common questions about this code of conduct, see the FAQ at [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at [https://www.contributor-covenant.org/translations][translations].

[homepage]: https://www.contributor-covenant.org
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
[Mozilla CoC]: https://github.com/mozilla/diversity
[FAQ]: https://www.contributor-covenant.org/faq
[translations]: https://www.contributor-covenant.org/translations
95 changes: 95 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Contributing to GoStructDB

Thanks for your interest in improving GSDB! Bug reports, docs fixes, tests and features are
all welcome.

By taking part you agree to follow our [Code of Conduct](CODE_OF_CONDUCT.md).

## Before you start

- **Bugs:** search [existing issues](https://github.com/SpaceTent/GoStructDB/issues) first,
then open a bug report with a minimal reproduction (struct, table schema, GSDB calls).
- **Features:** open a feature request to discuss the idea before writing a lot of code.
GSDB is deliberately opinionated (SQL stays visible, structs stay primitive), so it's
worth checking the idea fits.
- **Security issues:** don't open a public issue; follow [SECURITY.md](SECURITY.md).

## Development setup

You need:

- Go **1.26+** (see `go.mod`)
- A C compiler (`gcc`/`clang`) with cgo enabled, for `mattn/go-sqlite3`
- Optional: `goimports` and `govulncheck` (used by `make fmt` / `make commit`)

```bash
git clone https://github.com/SpaceTent/GoStructDB.git
cd GoStructDB
go build ./...
go test ./...
```

You don't need a database server to run the tests: unit tests use
[`go-sqlmock`](https://github.com/DATA-DOG/go-sqlmock) and the integration tests use a
temporary SQLite file.

Optional tools:

```bash
go install golang.org/x/tools/cmd/goimports@latest
go install golang.org/x/vuln/cmd/govulncheck@latest
```

## Making changes

1. Fork the repo and create a branch from `main`:
`git checkout -b fix/short-description` (or `feat/...`, `docs/...`, `test/...`).
2. Make your change. Keep it focused: one fix or feature per pull request.
3. Add or update tests in `gsdb/*_test.go`. Table-driven tests with `testify/assert`
match the existing style.
4. Format, vet and test:

```bash
gofmt -s -w .
goimports -w . # if installed
go vet ./...
go test ./... # or: make test (writes profile.cov with coverage)
```

5. Update `README.md` / `docs/` if behaviour or the API changed, and add a line under
**Unreleased** in [CHANGELOG.md](CHANGELOG.md).

### Make targets

| Target | What it does |
| --- | --- |
| `make test` | `go test -v -coverprofile=profile.cov ./...` |
| `make fmt` | `go mod tidy`, `goimports`, `gofmt -s` |
| `make run` | Formats, then runs `main.go` (all examples; see [examples/README.md](examples/README.md)) |
| `make commit` / `make release` | Maintainer shortcuts that commit, tag and **push**. Contributors should use normal git and pull requests instead. |

## Commit messages

Short, imperative subject lines. A [Conventional Commits](https://www.conventionalcommits.org/)
style prefix is preferred and already used in the history:

```text
fix: handle NULL dates in QuerySingleStruct
feat: support uint primary keys in Save
docs: document readdefault=null
test: add Update tests for bool fields
chore: bump go-sql-driver/mysql
```

## Pull requests

- Open the PR against `main` and fill in the template.
- CI (`.github/workflows/go.yml`) runs `go test -v ./...` on every pull request; it must pass.
- Keep PRs small enough to review. Explain *why* as well as *what*.
- Maintainers may squash commits when merging.

## Releases (maintainers)

Releases are tagged `v0.0.N`. Pushing a `v*` tag runs `.github/workflows/release.yml`, which
creates a GitHub release with generated notes. Move the **Unreleased** entries in
`CHANGELOG.md` under the new version when tagging.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 SpaceTent

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading
Loading