That is just a fragment of the code. What does the func line look
like? That is the error message I would expect to see if your
function does not have a return type.
Ian
func ReadConfig() ([]uint8) {
backupDir, err := ioutil.ReadFile(Home + "/.backup-lightrc")if err != nil {fmt.Printf("Error: Can't read config file, %s", err.String())os.Exit(1)}Config.Close()return backupDirBecause I am using := to declare the variable that I am wanting to return
I assume it is []uint8, if I am wrong about this could that be why it is throwing me that error?
A string variable has type string, not type []uint8.
A string variable has type string, not type []uint8.
Yes, they can. := is a shorthand declaration; it doesn't stop the
things it declares being explicit operands of a return statement.
In Chris's example,func ForExample( i int ) (result string) { ... return ... }"result" is what he is calling a return variable (I'd prefer "return parameter" or at least "named return variable" to avoid confusion with a regular variable whose contents you happen to be returning).