Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Use the <a href="http://golang.org/pkg/reflect/">reflect</a> package:</p> <blockquote> <p>Package reflect implements run-time reflection, allowing a program to manipulate objects with arbitrary types. The typical use is to take a value with static type interface{} and extract its dynamic type information by calling TypeOf, which returns a Type.</p> </blockquote> <pre><code>package main import ( "fmt" "reflect" ) func main() { b := true s := "" n := 1 f := 1.0 a := []string{"foo", "bar", "baz"} fmt.Println(reflect.TypeOf(b)) fmt.Println(reflect.TypeOf(s)) fmt.Println(reflect.TypeOf(n)) fmt.Println(reflect.TypeOf(f)) fmt.Println(reflect.TypeOf(a)) } </code></pre> <p>Produces:</p> <blockquote> <blockquote> <p>bool<br> string<br> int<br> float64<br> []string </p> </blockquote> </blockquote> <p><a href="http://play.golang.org/p/_KymowlCWY">Playground</a></p> <p>Example using <code>ValueOf(i interface{}).Kind()</code>:</p> <pre><code>package main import ( "fmt" "reflect" ) func main() { b := true s := "" n := 1 f := 1.0 a := []string{"foo", "bar", "baz"} fmt.Println(reflect.ValueOf(b).Kind()) fmt.Println(reflect.ValueOf(s).Kind()) fmt.Println(reflect.ValueOf(n).Kind()) fmt.Println(reflect.ValueOf(f).Kind()) fmt.Println(reflect.ValueOf(a).Index(0).Kind()) // For slices and strings } </code></pre> <p>Produces:</p> <blockquote> <blockquote> <p>bool<br> string<br> int<br> float64<br> string</p> </blockquote> </blockquote> <p><a href="http://play.golang.org/p/NdALPCv0RF">Playground</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload