24 lines
404 B
Go
24 lines
404 B
Go
|
package utils
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"io"
|
||
|
"os"
|
||
|
)
|
||
|
|
||
|
func CreateFile(ctx context.Context, filePath string) (io.Writer, error) {
|
||
|
file, err := os.Create(filePath)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return file, nil
|
||
|
}
|
||
|
|
||
|
func OpenFile(ctx context.Context, filePath string) (io.Reader, error) {
|
||
|
file, err := os.OpenFile(filePath, os.O_RDONLY, 0644)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return file, nil
|
||
|
}
|