{"id":31757039,"url":"https://github.com/toru/nullable","last_synced_at":"2026-05-15T22:04:35.920Z","repository":{"id":156900684,"uuid":"620095693","full_name":"toru/nullable","owner":"toru","description":"Productive syntax for the nullable data types in Go's standard database/sql package. ActiveSupport inspired.","archived":false,"fork":false,"pushed_at":"2024-03-21T03:38:38.000Z","size":52,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-03-21T04:35:02.697Z","etag":null,"topics":["activesupport","database","go","null"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/toru/nullable","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/toru.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}},"created_at":"2023-03-28T02:40:32.000Z","updated_at":"2023-04-27T05:39:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"b53a5285-2cf2-45c4-8774-f5af290924c4","html_url":"https://github.com/toru/nullable","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/toru/nullable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toru%2Fnullable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toru%2Fnullable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toru%2Fnullable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toru%2Fnullable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/toru","download_url":"https://codeload.github.com/toru/nullable/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toru%2Fnullable/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001960,"owners_count":26083244,"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","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["activesupport","database","go","null"],"created_at":"2025-10-09T19:46:53.899Z","updated_at":"2026-05-15T22:04:35.911Z","avatar_url":"https://github.com/toru.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nullable\n\n[![go workflow](https://github.com/toru/nullable/actions/workflows/go.yml/badge.svg)](https://github.com/toru/nullable/actions/workflows/go.yml)\n[![go reference](https://pkg.go.dev/badge/github.com/toru/nullable.svg)](https://pkg.go.dev/github.com/toru/nullable)\n[![mit license](https://img.shields.io/badge/license-MIT-green)](/LICENSE)\n\nThe nullable package provides an unobtrusive, [Active Support](https://guides.rubyonrails.org/active_support_core_extensions.html)\ninspired syntax on top of Go's standard [database/sql](https://github.com/golang/go/tree/master/src/database/sql) types.\nBecause nullable wraps the standard package, it is a simple drop-in replacement.\n\n## Quick Examples\n\nUsage within struct definition.\n\n```go\ntype IceCream struct {\n  // Using the nullable package\n  Flavor nullable.String `db:\"flavor\"`\n\n  // Using the database/sql package\n  Topping sql.NullString `db:\"topping\"`\n}\n```\n\n### String\n\n#### Initialization\n\n```go\n// Using the nullable package\nnullable.NewString(\"hello\")\n\n// Equivalent using the standard type\nsql.NullString{String: \"hello\", Valid: true}\n```\n\n#### Mutation\n\n```go\n// Overwrite the existing value\nvalue.Set(\"hello there\")\n```\n\n#### Checking State\n\n```go\n// Null() is also available\nif value.Nil() {\n  log.Println(\"stored as NULL in the database\")\n}\n\nif value.Present() {\n  log.Println(\"non-empty string\")\n}\n\nif value.Empty() {\n  log.Println(\"either NULL or empty string\")\n}\n```\n\n#### Utilities\n\n```go\n// Hexadecimal string representation of the underlying value\nvalue.HexString()\n```\n\n### Binary\n\n#### Initialization\n\n```go\nnullable.NewBinary([]byte(\"hello\"))\n```\n\n#### Checking State\n\n```go\nif value.Nil() {\n  log.Println(\"stored as NULL in the database\")\n}\n\nif value.Present() {\n  log.Println(\"non-empty byte slice\")\n}\n```\n\n#### Utilities\n\n```go\n// Hexadecimal string representation of the underlying bytes\nvalue.HexString()\n```\n\nFor all available types, see the [package documentation](https://pkg.go.dev/github.com/toru/nullable).\n\n## Motivation\n\nGo's standard library provides precisely what it should: well-thought-out\nprimitive building blocks. This package scratches the itch of those who avoid\nORMs but still miss the ergonomics of Rails when handling nullable values.\n\n## Contributing\n\nContributions of any kind are welcome! If you are going to submit a PR, please\nfollow [Go's commit message structure](https://go.dev/wiki/CommitMessage).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoru%2Fnullable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftoru%2Fnullable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoru%2Fnullable/lists"}