Question: I'm brand new to Go and having trouble getting fmt.scan() to fill a slice. The number of input values is dynamic and I can't use a for loop. My initial thought was to try this:

```
package main

import "fmt"

func main() {
    var x []int
    fmt.Println("Enter input")
    fmt.Scanf("%v", append(x))
    fmt.Println(x)
}

```

Which obviously doesn't work. Can someone point me in the right direction?

Answer: 
> 
> [Get] `fmt.Scan()` to fill a slice. The number of input values is dynamic and I can't use a for loop.
> 
> 
> 

---

Perhaps, something like this:

```
package main

import "fmt"

func input(x []int, err error) []int {
    if err != nil {
        return x
    }
    var d int
    n, err := fmt.Scanf("%d", &d)
    if n == 1 {
        x = append(x, d)
    }
    return input(x, err)
}

func main() {
    fmt.Println("Enter input:")
    x := input([]int{}, nil)
    fmt.Println("Input:", x)
}

```

Output:

```
Enter input:
 1
2 3
4
 5  6  7

Input: [1 2 3 4 5 6 7]

```

---

ADDENDUM:

When storage is allocated for a variable or a new value is created, and no explicit initialization is provided, the variable or value is given a default value, [the zero value](https://golang.org/ref/spec#The_zero_value) for its type: `nil` for slices. [Conversions](https://golang.org/ref/spec#Conversions) are expressions of the form `T(x)` where `T` is a type and `x` is an expression that can be converted to type `T`. `[]int(nil)` is a conversion to the zero value for the slice value `[]int`. 

```
x := input([]int(nil), nil)

```

is equivalent to 

```
x := input([]int{}, nil)

```

or

```
var x []int
x = input(x, nil)

```

I have revised my answer to use:

```
x := input([]int{}, nil)

```
I'm new to Go, so this are my 2cents as a newbie.

```
func main(){
    var numsToInput int 

    fmt.Println("Welcome user!")
    fmt.Println("How many numbers would you like to scale today?")
    fmt.Scan(&numsToInput)

    fmt.Println("Type please the ", num, " numbers: ")

    var values []float32 // Empty slice

    for i := 0; i < num; i++{
        var val float32
        fmt.Scanln(&val)
        values = append(values, val)
    }
    fmt.Println(values)
}

```

It's not a very elaborate program, but certainly it's simple.

I hope it was useful.