Reflection / Slice / Essential Go

Run Settings
LanguageGo
Language Version
Run Command
package main import ( "fmt" "reflect" ) func main() { typ := reflect.SliceOf(reflect.TypeOf("example")) // create slice with capacity 10 and length 1 rv := reflect.MakeSlice(typ, 1, 10) rv.Index(0).SetString("foo") a := rv.Interface().([]string) fmt.Printf("a: %#v\n", a) }
Editor Settings
Theme
Key bindings
Full width
Lines