개요
- Go 파일 읽기
hello
package main
import (
"fmt"
"os"
)
func main() {
fileBytes, err := os.ReadFile("greet.txt")
if err != nil {
panic(err)
}
fmt.Println(fileBytes) // [104 101 108 108 111]
fmt.Println(string(fileBytes)) // hello
}
hello
package main
import (
"fmt"
"os"
)
func main() {
fileBytes, err := os.ReadFile("greet.txt")
if err != nil {
panic(err)
}
fmt.Println(fileBytes) // [104 101 108 108 111]
fmt.Println(string(fileBytes)) // hello
}