Documentation

Overview

    Package reflecttools provides utility functions for working with Go's reflect package.

    These functions are highly specific to Granitic's internal use of reflection and are not recommended for use in user applications.

    Index

    Constants

    This section is empty.

    Variables

    This section is empty.

    Functions

    func ExtractDotPath

    func ExtractDotPath(path string) []string

      ExtractDotPath converts a dot-delimited path into a string array of its constiuent parts. E.g. "a.b.c" becomes ["a","b","c"]

      func FieldValue

      func FieldValue(i interface{}, name string) reflect.Value

        FieldValue assumes the supplied interface is a pointer to a struct, an interface or a struct and has a valid field of the supplied name, then returns the reflect value of that field.

        func FindNestedField

        func FindNestedField(path []string, v interface{}) (reflect.Value, error)

          FindNestedField take the output of ExtractDotPath and uses it to traverse an object graph to find a value. Apart from final value, each intermediate step in the graph must be a struct or pointer to a struct.

          func HasFieldOfName

          func HasFieldOfName(i interface{}, fieldName string) bool

            HasFieldOfName assumes the supplied interface is a pointer to a struct and checks to see if the underlying struct has a field of the supplied name. It does not check to see if the field is writable.

            func HasWritableFieldOfName

            func HasWritableFieldOfName(i interface{}, fieldName string) bool

              HasFieldOfName assumes the supplied interface is a pointer to a struct and checks to see if the underlying struct has a writable field of the supplied name.

              func IsPointer

              func IsPointer(p interface{}) bool

              func IsPointerToStruct

              func IsPointerToStruct(p interface{}) bool

                IsPointerToStruct returns true if the supplied interfaces is a pointer to a struct.

                func IsSliceOrArray

                func IsSliceOrArray(i interface{}) bool

                func IsZero

                func IsZero(i interface{}) bool

                  IsZero returns true if i is set to the zero value of i's type

                  func NilMap

                  func NilMap(v reflect.Value) bool

                    NilPointer returns true is the supplied reflect value is a Map and is nil.

                    func NilPointer

                    func NilPointer(v reflect.Value) bool

                      NilPointer returns true if the supplied reflect value is a pointer that does not point a valid value.

                      func SetBool

                      func SetBool(i interface{}, name string, b bool)

                        SetBool assumes that the supplied interface is a pointer to a struct and has a writable bool field of the supplied name, then sets the field of the supplied value.

                        func SetFieldPtrToStruct

                        func SetFieldPtrToStruct(tfv reflect.Value, valuePointer interface{}) error

                        func SetFloat64

                        func SetFloat64(i interface{}, name string, v float64)

                          SetFloat64 assumes that the supplied interface is a pointer to a struct and has a writable float64 field of the supplied name, then sets the field of the supplied value.

                          func SetInt64

                          func SetInt64(i interface{}, name string, v int64)

                            SetInt64 assumes that the supplied interface is a pointer to a struct and has a writable int64 field of the supplied name, then sets the field of the supplied value.

                            func SetPtrToStruct

                            func SetPtrToStruct(target interface{}, field string, valuePointer interface{}) error

                              SetPtrToStruct is used to inject an object into the specified field on a another object. The target object, supplied value and the type of the named target field must all be a pointer to a struct.

                              func SetString

                              func SetString(i interface{}, name string, s string)

                                SetString assumes that the supplied interface is a pointer to a struct and has a writable string field of the supplied name, then sets the field of the supplied value.

                                func SetUint64

                                func SetUint64(i interface{}, name string, v uint64)

                                  SetUint64 assumes that the supplied interface is a pointer to a struct and has a writable uint64 field of the supplied name, then sets the field of the supplied value.

                                  func TargetFieldIsArray

                                  func TargetFieldIsArray(i interface{}, name string) bool

                                    TargetFieldIsArray assumes the supplied interface is a pointer to a struct, an interface or a struct and has a valid field of the supplied name, then returns true if the reflect type of that field is Array. Note that this method will return false for Slice fields.

                                    func TypeOfField

                                    func TypeOfField(i interface{}, name string) reflect.Type

                                      TypeOfField assumes the supplied interface is a pointer to a struct and that the supplied field name exists on that struct, then finds the reflect type of that field.

                                      Types

                                      This section is empty.

                                      Source Files