Upgrade to Go 1.19
This commit is contained in:
parent
2d06e8e09c
commit
741f18efd1
9 changed files with 20 additions and 28 deletions
10
app/app.go
10
app/app.go
|
|
@ -12,8 +12,8 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
APP_NAME = "Git repository manager"
|
||||
APP_DESCRIPTION = "Manage your repository with simple app"
|
||||
AppName = "Git repository manager"
|
||||
AppDescription = "Manage your repository with simple app"
|
||||
VERSION = "0.3.0"
|
||||
errNotFoundTags = "no repository was found with the specified tags"
|
||||
errNotFoundName = "no repository was found with the specified name"
|
||||
|
|
@ -25,7 +25,7 @@ type GitRepositoryManager struct {
|
|||
}
|
||||
|
||||
func (g *GitRepositoryManager) Parse(args []string) error {
|
||||
arguments, err := config.ParseCliArguments(APP_NAME, APP_DESCRIPTION, args)
|
||||
arguments, err := config.ParseCliArguments(AppName, AppDescription, args)
|
||||
if err != nil {
|
||||
fmt.Printf("Error: %v", err.Error())
|
||||
return err
|
||||
|
|
@ -37,13 +37,13 @@ func (g *GitRepositoryManager) Parse(args []string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
fileExcension, err := getFileExcension(arguments.ConfigurationFile)
|
||||
fileExtension, err := getFileExtension(arguments.ConfigurationFile)
|
||||
if err != nil {
|
||||
fmt.Printf("Error: %v", err.Error())
|
||||
return err
|
||||
}
|
||||
|
||||
configuration, err := config.GetRepositoryConfig(configFileContent, fileExcension)
|
||||
configuration, err := config.GetRepositoryConfig(configFileContent, fileExtension)
|
||||
if err != nil {
|
||||
fmt.Printf("Error: %v", err.Error())
|
||||
return err
|
||||
|
|
|
|||
16
app/utils.go
16
app/utils.go
|
|
@ -3,27 +3,27 @@ package app
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"gitlab.com/revalus/grm/config"
|
||||
)
|
||||
|
||||
func getFileContent(pathToFile string) ([]byte, error) {
|
||||
return ioutil.ReadFile(pathToFile)
|
||||
return os.ReadFile(pathToFile)
|
||||
}
|
||||
|
||||
func getFileExcension(pathToFile string) (string, error) {
|
||||
splittedFileName := strings.Split(pathToFile, ".")
|
||||
func getFileExtension(pathToFile string) (string, error) {
|
||||
splitFileName := strings.Split(pathToFile, ".")
|
||||
|
||||
if len(splittedFileName) == 1 {
|
||||
msg := fmt.Sprintf("excension for file \"%v\", not found", splittedFileName)
|
||||
if len(splitFileName) == 1 {
|
||||
msg := fmt.Sprintf("excension for file \"%v\", not found", splitFileName)
|
||||
return "", errors.New(msg)
|
||||
}
|
||||
|
||||
fileExcension := splittedFileName[len(splittedFileName)-1]
|
||||
fileExtension := splitFileName[len(splitFileName)-1]
|
||||
|
||||
return fileExcension, nil
|
||||
return fileExtension, nil
|
||||
}
|
||||
|
||||
func checkIsItemInSlice(check string, sliceToCheck []string) bool {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ func TestGetFileExtension(t *testing.T) {
|
|||
}
|
||||
|
||||
for key, value := range toTest {
|
||||
result, err := getFileExcension(key)
|
||||
result, err := getFileExtension(key)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error: %v", err)
|
||||
|
|
@ -32,7 +32,7 @@ func TestGetFileExtension(t *testing.T) {
|
|||
|
||||
func TestErrorInGetExcensionFile(t *testing.T) {
|
||||
|
||||
result, err := getFileExcension("test")
|
||||
result, err := getFileExtension("test")
|
||||
|
||||
if err == nil {
|
||||
t.Errorf("Expected to get error, instead of this got result %v", result)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue