From 03a473b19d003db7db5c8a0f36dd7c182c8002a5 Mon Sep 17 00:00:00 2001 From: cangui Date: Thu, 12 Dec 2024 09:19:49 +0100 Subject: [PATCH] Update code sheet --- function/main.go | 15 +++------------ main.go | 11 +++-------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/function/main.go b/function/main.go index b6960cf..573f3cd 100644 --- a/function/main.go +++ b/function/main.go @@ -7,7 +7,7 @@ import ( "github.com/xuri/excelize/v2" ) -func ReadExcel(path string)[]map[string]string { +func ReadExcel(path string,sheetSelect string)[]map[string]string { // var sql []string // var pathSite []string @@ -25,18 +25,9 @@ func ReadExcel(path string)[]map[string]string { fmt.Println(err) } }() - // Get value from cell by given worksheet name and cell reference. - cell, err := f.GetCellValue("julien", "A2") - if err != nil { - fmt.Println(err) - return nil - } - fmt.Println("-------------------------------------") - fmt.Println(cell) - fmt.Println("-------------------------------------") - // Get all the rows in the Sheet1. + // Nom de la feuille - sheetName := "julien" + sheetName := sheetSelect // Obtenir toutes les lignes rows, err := f.GetRows(sheetName) diff --git a/main.go b/main.go index ef80cbf..915ef71 100644 --- a/main.go +++ b/main.go @@ -6,9 +6,7 @@ import ( "log" "os" "strings" - "time" - "canguidev.fr/pvnet/function" simplyssh "canguidev.fr/pvnet/simply-ssh" "github.com/TwiN/go-choice" @@ -17,13 +15,10 @@ import ( ) func main() { - //var path string="/Users/cangui/.ssh/julien_pvnet" - ///Users/cangui/Documents/Dev peso/Golang dev/test.xlsx err := godotenv.Load() if err != nil { log.Fatal("Error loading .env file") } - var pathSsh string = os.Getenv("PATH_SSH") var pathConfigSsh = os.Getenv("PATH_SSH_CONF") var pathExcel string = os.Getenv("PATH_FOLDER") @@ -31,7 +26,7 @@ func main() { var mysqlPswd string var pathSaveSql string var nameBase string - + var sheetSelect string=os.Getenv("SHEET_SELECT") // Chargement de la liste des hosts du fichier config ssh d := simplyssh.GetHost(pathConfigSsh) var s []string @@ -41,7 +36,7 @@ func main() { } // selectionne du host choice, index, err := gochoice.Pick( - "What do you want to do?\nPick:", + "Sélectionner un vhost de connection?\nChoix:", s, ) selectHost := choice @@ -87,7 +82,7 @@ func main() { return } if index == 0 { - excel := function.ReadExcel(pathExcel) + excel := function.ReadExcel(pathExcel,sheetSelect) // Parcourir les résultats d'Excel for _, value := range excel { sessionBackup, err := client.NewSession()