I have lots of small files, I don\'t want to read them line by line.
Is there a function in Go that will read a whole file into a string variable?
This is how I did it:
package main import ( "fmt" "os" "bytes" "log" ) func main() { filerc, err := os.Open("filename") if err != nil{ log.Fatal(err) } defer filerc.Close() buf := new(bytes.Buffer) buf.ReadFrom(filerc) contents := buf.String() fmt.Print(contents) }