26 lines
509 B
Go
26 lines
509 B
Go
|
package app
|
||
|
|
||
|
import (
|
||
|
"errors"
|
||
|
"fmt"
|
||
|
"io/ioutil"
|
||
|
"strings"
|
||
|
)
|
||
|
|
||
|
func getFileContent(pathToFile string) ([]byte, error) {
|
||
|
return ioutil.ReadFile(pathToFile)
|
||
|
}
|
||
|
|
||
|
func getFileExcension(pathToFile string) (string, error) {
|
||
|
splittedFileName := strings.Split(pathToFile, ".")
|
||
|
|
||
|
if len(splittedFileName) == 1 {
|
||
|
msg := fmt.Sprintf("excension for file \"%v\", not found", splittedFileName)
|
||
|
return "", errors.New(msg)
|
||
|
}
|
||
|
|
||
|
fileExcension := splittedFileName[len(splittedFileName)-1]
|
||
|
|
||
|
return fileExcension, nil
|
||
|
}
|