reflect

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2015 License: MIT Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

This package provides some punk-rock reflection which is not in the stdlib.

Index

Constants

View Source
const TagName = "cql"

Variables

This section is empty.

Functions

func FieldsAndValues

func FieldsAndValues(val interface{}) ([]string, []interface{}, bool)

FieldsAndValues returns a list field names and a corresponing list of values for the given struct. For details on how the field names are determined please see StructToMap.

func MapToStruct

func MapToStruct(m map[string]interface{}, struc interface{}) error

MapToStruct converts a map to a struct. It is the inverse of the StructToMap function. For details see StructToMap.

func StructToMap

func StructToMap(val interface{}) (map[string]interface{}, bool)

StructToMap converts a struct to map. The object's default key string is the struct field name but can be specified in the struct field's tag value. The "cql" key in the struct field's tag value is the key name. Examples:

// Field appears in the resulting map as key "myName".
Field int `cql:"myName"`

// Field appears in the resulting as key "Field"
Field int

// Field appears in the resulting map as key "myName"
Field int "myName"

Types

This section is empty.

Jump to

Keyboard shortcuts

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