iszero

package module
v0.0.0-...-f48f9b3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2017 License: BSD-3-Clause, MIT Imports: 1 Imported by: 2

README

iszero

Go Report Card Codecov Build Status Go docs

A go package for checking if a value is zero.

I put this package together from code within the Go source, because I needed to be able to identify if a field in a struct was empty/its-zero-value, so that when encoding a struct I could determine if the field was empty and could be ommitted.

Usage

See the example in Go Docs.

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Value

func Value(v reflect.Value) bool

Value determines of the value is a zero value, which is the value the type has if declared without a defined value.

Example
package main

import (
	"fmt"
	"reflect"

	"4d63.com/iszero"
)

func main() {
	var s0 string
	s0Zero := iszero.Value(reflect.ValueOf(s0))

	var s1 string = "hello world"
	s1Zero := iszero.Value(reflect.ValueOf(s1))

	fmt.Println("s0", s0Zero)
	fmt.Println("s1", s1Zero)

}
Output:

s0 true
s1 false

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL