content/[] string
content/
$-> tree content/
content/
├── 1.txt
├── 2.txt
└── tmp

Here is what I currently got:

package main

import (
    "fmt"
    "io/ioutil"
)

func listFile() []string {
    list := make([]string, 100)
    // as you can see, I make a slice length as 100, but that is not appropriate.

    files, _ := ioutil.ReadDir("content")
    i := 0
    for _, f := range files{
        list[i] = f.Name()
        i = i+1
    }
    return list
}

func main(){
    fmt.Print(listFile())
}
ArrayListlist.add()

Can slice in GoLang do that?

Thanks.