{"id":13411643,"url":"https://github.com/emvi/null","last_synced_at":"2025-03-14T17:31:00.672Z","repository":{"id":57491775,"uuid":"139766763","full_name":"emvi/null","owner":"emvi","description":"Nullable Go types that can be marshalled/unmarshalled to/from JSON.","archived":false,"fork":false,"pushed_at":"2021-11-09T16:04:18.000Z","size":33,"stargazers_count":35,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-07-31T20:48:18.307Z","etag":null,"topics":["golang","json","marshal","nullable","nullbool","nullfloat64","nullint64","nullstring","nulltime","sql","unmarshal"],"latest_commit_sha":null,"homepage":null,"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/emvi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-04T21:18:45.000Z","updated_at":"2024-03-28T02:26:06.000Z","dependencies_parsed_at":"2022-09-26T18:50:31.459Z","dependency_job_id":null,"html_url":"https://github.com/emvi/null","commit_stats":null,"previous_names":["emvicom/null"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emvi%2Fnull","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emvi%2Fnull/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emvi%2Fnull/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emvi%2Fnull/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/emvi","download_url":"https://codeload.github.com/emvi/null/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243618652,"owners_count":20320270,"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":["golang","json","marshal","nullable","nullbool","nullfloat64","nullint64","nullstring","nulltime","sql","unmarshal"],"created_at":"2024-07-30T20:01:15.322Z","updated_at":"2025-03-14T17:31:00.278Z","avatar_url":"https://github.com/emvi.png","language":"Go","funding_links":[],"categories":["Data Integration Frameworks","Data Structures and Algorithms","数据结构与算法","Uncategorized","数据结构","Data Structures","Generators","数据结构`go语言实现的数据结构与算法`"],"sub_categories":["Nullable Types","可空类型","标准 CLI","Advanced Console UIs"],"readme":"# Nullable Go types\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/emvi/null?status.svg)](https://pkg.go.dev/github.com/emvi/null?status)\n[![CircleCI](https://circleci.com/gh/emvi/null.svg?style=svg)](https://circleci.com/gh/emvi/null)\n[![Go Report Card](https://goreportcard.com/badge/github.com/emvi/null)](https://goreportcard.com/report/github.com/emvi/null)\n\u003ca href=\"https://discord.gg/fAYm4Cz\"\u003e\u003cimg src=\"https://img.shields.io/discord/739184135649886288?logo=discord\" alt=\"Chat on Discord\"\u003e\u003c/a\u003e\n\n## Description\n\nThis package provides nullable Go types for bool, float64, int64, int32, string and time.Time replacing sql.NullString, sql.NullInt64, ... that can be marshalled/unmarshalled to/from JSON.\n\n## Installation\n\nTo install \"null\", run go get within your project:\n\n```\ngo get github.com/emvi/null\n```\n\nNote that from 1.3 on \"null\" requires Go version 1.13 or newer.\n\n## Usage\n\nHere is a short example demonstrating the string type. The other types (int64, float64 and bool) work in the same manner.\n\n```\npackage main\n\nimport (\n    \"encoding/json\"\n    \"database/sql\"\n    \"fmt\"\n\n    \"github.com/emvi/null\"\n)\n\ntype NullableString struct {\n    Value null.String `json:\"value\"`\n}\n\nfunc main() {\n    str := NullableString{null.NewString(\"nullable string\", true)}\n    // or long version: str := NullableString{null.String{sql.NullString{String: \"nullable string\", Valid: true}}}\n    \n    data, _ := json.Marshal(str)\n    fmt.Println(string(data)) // -\u003e {\"value\": \"nullable\"}\n\n    str.SetNil() // use str.SetValid(\"value\") to set a value again\n    data, _ = json.Marshal(str)\n    fmt.Println(string(data)) // -\u003e {\"value\": null}\n}\n```\n\n## Contribute\n\n[See CONTRIBUTING.md](CONTRIBUTING.md)\n\n## License\n\nMIT\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"nullgopher.svg\" width=\"300px\" /\u003e\n\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femvi%2Fnull","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femvi%2Fnull","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femvi%2Fnull/lists"}