GitRepositoryManager/app/utils.go

26 lines
509 B
Go
Raw Permalink Normal View History

2021-11-02 18:19:31 +00:00
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
}