Advertisement
Guest User

Untitled

a guest
Sep 16th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.39 KB | None | 0 0
  1. type MyStruct struct {
  2.     FirstName       [7]rune
  3.     LastName        [7]rune
  4.     Organization    [7]rune
  5. }
  6.  
  7. func main () {
  8.     text := "John   Smith  Demo   "
  9.     runes := []rune(text)
  10.     str := reflect.New(MyStruct).Elem()
  11.     for i := 0; i < str.NumField(); i++ {
  12.         // reflect.Set: value of type []int32 is not assignable to type [7]int32
  13.         str.Field(i).Set(reflect.ValueOf(runes[:end]))
  14.         runes = runes[end:]
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement