feat!: update get from (V, error) to (V, bool) #20

Merged
mvhutz merged 3 commits from feat/get-no-error into main 2026-04-14 01:58:16 +00:00
Owner

Description

Currently, the signature for Table.Get is func (K) (V, error). This is not very Go-idiomatic, which prefers to return a boolean instead of an error. For instance, a built-in Go map is used like so:

if value, ok := users[id]; !ok {
  // ...
}

Updating our table to look like that is best practice. In that same vein, to support direct lookup (i.e. v := users[id]), this PR also adds Table.Find.

Changes

  • BREAKING CHANGE: Update contract of Table.Get to func (K) (V, bool). Returns 'false' is the item cannot be found, and 'true' if it is found.
  • Add Table.Find.
  • Updated tests and documentation to match the change.

Design Decisions

  • Chose to make this decision because throwing an error implies that there is something 'wrong' with the table. There is nothing wrong with the table; it is just that the item does not exist.

Checklist

  • Tests pass
  • Docs updated
## Description Currently, the signature for `Table.Get` is `func (K) (V, error)`. This is not very Go-idiomatic, which prefers to return a boolean instead of an error. For instance, a built-in Go map is used like so: ```go if value, ok := users[id]; !ok { // ... } ``` Updating our table to look like that is best practice. In that same vein, to support direct lookup (i.e. `v := users[id]`), this PR also adds `Table.Find`. ## Changes - BREAKING CHANGE: Update contract of `Table.Get` to `func (K) (V, bool)`. Returns 'false' is the item cannot be found, and 'true' if it is found. - Add `Table.Find`. - Updated tests and documentation to match the change. ### Design Decisions - Chose to make this decision because throwing an error implies that there is something 'wrong' with the table. There is nothing wrong with the table; it is just that the item does not exist. ## Checklist - [x] Tests pass - [x] Docs updated
mvhutz added 1 commit 2026-04-03 19:40:06 +00:00
feat!: update contract for 'Table.Get()'
All checks were successful
CI / Check PR Title (pull_request) Successful in 19s
CI / Go Lint (pull_request) Successful in 42s
CI / Markdown Lint (pull_request) Successful in 22s
CI / Makefile Lint (pull_request) Successful in 40s
CI / Unit Tests (pull_request) Successful in 37s
CI / Fuzz Tests (pull_request) Successful in 1m12s
CI / Mutation Tests (pull_request) Successful in 1m18s
95687acade
mvhutz changed title from feat!: update get from (V, error) to (V, bool) to feat!: update get from `(V, error)` to `(V, bool)` 2026-04-03 19:40:40 +00:00
mvhutz added 1 commit 2026-04-14 01:36:49 +00:00
Merge remote-tracking branch 'origin' into feat/get-no-error
All checks were successful
CI / Check PR Title (pull_request) Successful in 29s
CI / Go Lint (pull_request) Successful in 41s
CI / Makefile Lint (pull_request) Successful in 37s
CI / Markdown Lint (pull_request) Successful in 32s
CI / Unit Tests (pull_request) Successful in 39s
CI / Fuzz Tests (pull_request) Successful in 1m37s
CI / Mutation Tests (pull_request) Successful in 1m19s
572e59f33d
mvhutz added 1 commit 2026-04-14 01:54:19 +00:00
feat: Table.Find
All checks were successful
CI / Check PR Title (pull_request) Successful in 29s
CI / Go Lint (pull_request) Successful in 42s
CI / Markdown Lint (pull_request) Successful in 31s
CI / Makefile Lint (pull_request) Successful in 40s
CI / Unit Tests (pull_request) Successful in 39s
CI / Fuzz Tests (pull_request) Successful in 1m40s
CI / Mutation Tests (pull_request) Successful in 1m23s
81ce24e7b7
mvhutz merged commit 42c5b5f8f4 into main 2026-04-14 01:58:16 +00:00
mvhutz deleted branch feat/get-no-error 2026-04-14 01:58:16 +00:00
Sign in to join this conversation.