https://github.com/unsafe-risk/go-safe
Use nil safety value
https://github.com/unsafe-risk/go-safe
go golang nil null-check null-safety safe
Last synced: about 1 year ago
JSON representation
Use nil safety value
- Host: GitHub
- URL: https://github.com/unsafe-risk/go-safe
- Owner: unsafe-risk
- License: mit
- Created: 2022-05-20T10:38:04.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2025-05-07T06:41:46.000Z (about 1 year ago)
- Last Synced: 2025-05-07T22:44:30.198Z (about 1 year ago)
- Topics: go, golang, nil, null-check, null-safety, safe
- Language: Go
- Homepage:
- Size: 20.5 KB
- Stars: 8
- Watchers: 1
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Go Safe
[](https://pkg.go.dev/github.com/unsafe-risk/go-safe)
## Description
Use nil safety value
## Install
```
go get github.com/unsafe-risk/go-safe
```
## Usage
```go
import (
// ...
safe "github.com/unsafe-risk/go-safe"
)
```
[https://pkg.go.dev/github.com/unsafe-risk/go-safe](https://pkg.go.dev/github.com/unsafe-risk/go-safe)
- TimeOrNow(t *time.Time) time.Time
- StrOrZero(s *string) string
- IOrZero(n *int) int
- I8OrZero(n *int8) int8
- I16OrZero(n *int16) int16
- I32OrZero(n *int32) int32
- I64OrZero(n *int64) int64
- UiOrZero(n *uint) uint
- Ui8OrZero(n *uint8) uint8
- Ui16OrZero(n *uint16) uint16
- Ui32OrZero(n *uint32) uint32
- Ui64OrZero(n *uint64) uint64
- F32OrZero(n *float32) float32
- F64OrZero(n *float64) float64
---
- TimeOrDefault(t *time.Time, def func() time.Time) time.Time
- StrOrDefault(s *string, def func() string) string
- IOrDefault(n *int, def func() int) int
- I8OrDefault(n *int8, def func() int8) int8
- I16OrDefault(n *int16, def func() int16) int16
- I32OrDefault(n *int32, def func() int32) int32
- I64OrDefault(n *int64, def func() int64) int64
- UiOrDefault(n *uint, def func() uint) uint
- Ui8OrDefault(n *uint8, def func() uint8) uint8
- Ui16OrDefault(n *uint16, def func() uint16) uint16
- Ui32OrDefault(n *uint32, def func() uint32) uint32
- Ui64OrDefault(n *uint64, def func() uint64) uint64
- F32OrDefault(n *float32, def func() float32) float32
- F64OrDefault(n *float64, def func() float64) float64
---
- StrZero() string
- IZero() int
- I8Zero() int8
- I16Zero() int16
- I32Zero() int32
- I64Zero() int64
- UiZero() uint
- Ui8Zero() uint8
- Ui16Zero() uint16
- Ui32Zero() uint32
- Ui64Zero() uint64
- F32Zero() float32
- F64Zero() float64