Answers for "golang io read file"

Go
3

golang read file

dat, err := ioutil.ReadFile("/tmp/dat")
    check(err)
    fmt.Print(string(dat))
Posted by: Guest on November-02-2020
1

golang read file

file_data, err := ioutil.ReadFile("./index.html")
if err != nil {
	fmt.Println(err)
}
fmt.Println(file_data)
Posted by: Guest on February-04-2022
0

golang read file

package main

import (
	"fmt"
	"io/fs"
	"os"
)

func main() {
	data, _ := fs.ReadFile(os.DirFS("."), "index.txt")
	fmt.Println(string(data))
}
Posted by: Guest on April-08-2022

Browse Popular Code Answers by Language