zero

package module
v0.0.0-...-4a4535d Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2016 License: MIT Imports: 1 Imported by: 49

README

cydev/zero

Check if golang struct is empty

Build Status Coverage Status GoDoc

package main

import (
        "fmt"

        "github.com/cydev/zero"
)

type Structure struct {
        ID int
}

func ExampleStructure() {
        zeroStructure := Structure{}
        zeroStructurePointer := &zeroStructure
        nonZero := Structure{ID: 1}
        nonZeroPointer := &nonZero
        fmt.Println(zero.IsZero(zeroStructure))        // true
        fmt.Println(zero.IsZero(zeroStructurePointer)) // true
        fmt.Println(zero.IsZero(nonZero))              // false
        fmt.Println(zero.IsZero(nonZeroPointer))       // false
        // Output:
        // true
        // true
        // false
        // false
}

func main() {
        ExampleStructure()
}

Documentation

Overview

Package zero provides a zero check for arbitrary values.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsZero

func IsZero(v interface{}) bool

IsZero reports whether v is zero struct Does not support cycle pointers for performance, so as json

Types

This section is empty.

Jump to

Keyboard shortcuts

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