mirror of
https://github.com/Direct-Dev-Ru/go-lcg.git
synced 2025-11-16 09:39:56 +00:00
25 lines
379 B
Go
25 lines
379 B
Go
package reader
|
|
|
|
import (
|
|
"bufio"
|
|
"os"
|
|
)
|
|
|
|
func FileToPrompt(cmd *string, filePath string) error {
|
|
f, err := os.Open(filePath)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer f.Close()
|
|
reader := bufio.NewReader(f)
|
|
*cmd = *cmd + "\nFile path: " + filePath + "\n"
|
|
for {
|
|
line, err := reader.ReadString('\n')
|
|
if err != nil {
|
|
break
|
|
}
|
|
*cmd = *cmd + "\n" + line
|
|
}
|
|
return nil
|
|
}
|