GoLang:无法在多个分配中将[] byte分配给z(类型字符串)

I'm trying to find the contents of files within a folder, so I'm listing what's in the folder then while looping through it I'm trying to read the files.

files, _ := ioutil.ReadDir("documents/")
for _, f := range files {
        //fmt.Println(f.Name())

    z := "documents/" + f.Name()
    fmt.Println(z) // prints out 'documents/*doc name*' recursively
    z, err := ioutil.ReadFile(z) // This line throws up the error

The error I get is: test.go:85: cannot assign []byte to z (type string) in multiple assignment

Any help? (This is my first time coding in Go)

Thanks!

You can convert []byte to string, but you cannot convert one value of a multiple return valued function.

buf, err := ioutil.ReadFile(z)
if err != nil {
        log.Fatal(err)
}
z = string(buf)

However, quite often it's better to not convert binary data to strings and work directly with buf.