Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vikyd/zero
Check default zero values of Golang
https://github.com/vikyd/zero
constant golang nil value zero
Last synced: about 9 hours ago
JSON representation
Check default zero values of Golang
- Host: GitHub
- URL: https://github.com/vikyd/zero
- Owner: vikyd
- License: mit
- Created: 2018-11-13T08:41:55.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-09-21T14:29:34.000Z (about 5 years ago)
- Last Synced: 2024-08-03T14:07:55.872Z (3 months ago)
- Topics: constant, golang, nil, value, zero
- Language: Go
- Homepage:
- Size: 4.88 KB
- Stars: 14
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# zero
Golang [The zero value](https://golang.org/ref/spec#The_zero_value)Check if a variable is its type's `zero value` or `default value`
The variable type can be any type:
- nil
- int
- float
- string
- slice
- struct
- channel
- map
- byte
- interface# Install
`go get -u github.com/vikyd/zero`
# Usage
```go
package main
import (
"fmt"
"github.com/vikyd/zero"
)func main() {
var v int
fmt.Println(zero.IsZeroVal(v))
}
```# Thanks
[newacct](https://stackoverflow.com/a/13906031/2752670)