21 lines
305 B
Go
21 lines
305 B
Go
package main
|
|
|
|
import (
|
|
"io"
|
|
"os"
|
|
)
|
|
|
|
func ReadFile(path string) ([]byte, error) {
|
|
file, err := os.Open(path)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer file.Close()
|
|
return io.ReadAll(file)
|
|
}
|
|
|
|
func ReadFileString(path string) (string, error) {
|
|
data, err := ReadFile(path)
|
|
return string(data), err
|
|
}
|