Golang: How to convert string to []int?
<p>I tackle with <a href="http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A" rel="nofollow">this question</a>.</p>

<p>I need to convert strings to int.
In this case, I need to convert "5 2 4 6 1 3" to, for example, [6]int{5,2,4,6,1,3}.
I wrote following this code, especially <code>AizuArray()</code>.
It seems elements are int <a href="https://ideone.com/3yersW" rel="nofollow">here</a>.
Would you please let me know if my way is correct?
Or could you let me know the better ways?
I ask this because I feel my way would be redundant and <a href="http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=1841434#1" rel="nofollow">Java way</a> is much easier.
Thank you.</p>

<pre><code>package main

import (
    "fmt"
    "reflect"
    "strconv"
    "strings"
)

func AizuArray(A string, N string) []int {
    a := strings.Split(A, " ")
    n, _ := strconv.Atoi(N) // int 32bit
    b := make([]int, n)
    for i, v := range a {
        b[i], _ = strconv.Atoi(v)
    }
    return b
}

func main() {
    A := "5 2 4 6 1 3"
    N := "6"
    j := strings.Split(A, " ")
    for _, v := range j {
        fmt.Println(reflect.TypeOf(v))
    }
    b := AizuArray(A, N)
    fmt.Println(b)
    for _, v := range b {
        fmt.Println(reflect.TypeOf(v))
    }
}
</code></pre>