https://github.com/disgoorg/omit
https://github.com/disgoorg/omit
golang omit optional-type
Last synced: 12 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/disgoorg/omit
- Owner: disgoorg
- License: apache-2.0
- Created: 2025-02-15T16:48:47.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-04-19T10:30:48.000Z (about 1 year ago)
- Last Synced: 2025-05-04T09:14:18.022Z (about 1 year ago)
- Topics: golang, omit, optional-type
- Language: Go
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://pkg.go.dev/github.com/disgoorg/omit)
[](https://goreportcard.com/report/github.com/disgoorg/omit)
[](https://golang.org/doc/devel/release.html)
[](https://github.com/disgoorg/omit/blob/master/LICENSE)
[](https://github.com/disgoorg/omit/releases/latest)
[](https://discord.gg/9tKpqXjYVC)
# omit
omit is a simple library to handle optional and nullable struct field values for json serialization and deserialization in golang.
## Installation
```bash
go get github.com/disgoorg/omit
```
## Usage
```go
package main
import (
"encoding/json"
"fmt"
"github.com/disgoorg/omit"
)
type User struct {
ID int `json:"id"`
Name string `json:"name"`
Email omit.Omit[*string] `json:"email,omitzero"`
}
func main() {
u := User{
ID: 1,
Name: "John Doe",
Email: omit.NewPtr("test@example.com"),
}
// Marshal
data, err := json.Marshal(u)
if err != nil {
panic(err)
}
fmt.Println(string(data))
}
```
## Documentation
Documentation is wip and can be found under:
* [](https://pkg.go.dev/github.com/disgoorg/omit)
## Troubleshooting
For help feel free to open an issue or reach out on [Discord](https://discord.gg/9tKpqXjYVC)
## Contributing
Contributions are welcomed but for bigger changes we recommend first reaching out via [Discord](https://discord.gg/9tKpqXjYVC) or create an issue to discuss your problems, intentions and ideas.
## License
Distributed under the [](LICENSE). See LICENSE for more information.