1# Reflection Functions
2
3Sprig provides rudimentary reflection tools. These help advanced template
4developers understand the underlying Go type information for a particular value.
5
6Go has several primitive _kinds_, like `string`, `slice`, `int64`, and `bool`.
7
8Go has an open _type_ system that allows developers to create their own types.
9
10Sprig provides a set of functions for each.
11
12## Kind Functions
13
14There are two Kind functions: `kindOf` returns the kind of an object.
15
16```
17kindOf "hello"
18```
19
20The above would return `string`. For simple tests (like in `if` blocks), the
21`isKind` function will let you verify that a value is a particular kind:
22
23```
24kindIs "int" 123
25```
26
27The above will return `true`
28
29## Type Functions
30
31Types are slightly harder to work with, so there are three different functions:
32
33- `typeOf` returns the underlying type of a value: `typeOf $foo`
34- `typeIs` is like `kindIs`, but for types: `typeIs "*io.Buffer" $myVal`
35- `typeIsLike` works as `typeIs`, except that it also dereferences pointers.
36
37**Note:** None of these can test whether or not something implements a given
38interface, since doing so would require compiling the interface in ahead of time.
39
40## deepEqual
41
42`deepEqual` returns true if two values are ["deeply equal"](https://golang.org/pkg/reflect/#DeepEqual)
43
44Works for non-primitive types as well (compared to the built-in `eq`).
45
46```
47deepEqual (list 1 2 3) (list 1 2 3)
48```
49
50The above will return `true`
51