浏览代码

primo commit

Mauro 2 月之前
当前提交
7f5586d298
共有 3 个文件被更改,包括 30 次插入0 次删除
  1. 0 0
      README.md
  2. 3 0
      go.mod
  3. 27 0
      opt.go

+ 0 - 0
README.md


+ 3 - 0
go.mod

@@ -0,0 +1,3 @@
+module 966.it/opt
+
+go 1.23.4

+ 27 - 0
opt.go

@@ -0,0 +1,27 @@
+package optp
+
+import (
+    "fmt"
+    "os"
+    "flag"
+    )
+
+func Start() string {
+  fmt.Println("Analisi CommandLine Options")
+
+  iniFile := flag.String("i","mail.ini","Posizione Ini File - obbligatorio")
+  flag.Parse()
+  if ! flag.Parsed() {
+    fmt.Println("Errore, nessun parametro indicato")
+    os.Exit(2)
+  }
+ 
+  // verifica che il file passato sia valido.
+  _,err := os.Stat(*iniFile)
+  if err != nil {
+    fmt.Println("Errore nel controllo di",*iniFile)
+    os.Exit(1)
+  }
+
+  return *iniFile
+}