structutil

package
v1.7.37 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2019 License: MIT Imports: 3 Imported by: 3

Documentation

Overview

Utilities for working with and manipulating structs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyFunc

func CopyFunc(dest interface{}, source interface{}, fn StructValueFunc) error

func CopyNonZero

func CopyNonZero(dest interface{}, source interface{}) error

Copy all values from the source into the destination, provided the source value for the corresponding field is not that type's zero value.

Types

type StructValueFunc

type StructValueFunc func(field string, sourceValue interface{}, destValue interface{}) (interface{}, bool)

Receives a struct field name, the value of that field in the source struct, and the value for that field in the destination struct. Returns the value that should be placed in the destination struct fields. If the returned bool is false, no changes will be made.

Jump to

Keyboard shortcuts

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