github.com/sandwich-go/boost@v1.3.29/xcmd/README.md (about)

     1  # xcmd
     2  
     3  命令行参数或Env参数
     4  
     5  # 例子
     6  ```go
     7  var name1 = fmt.Sprintf("%sdebug", GetFlagPrefix())
     8  var name2 = fmt.Sprintf("%sp1", GetFlagPrefix())
     9  var name3 = fmt.Sprintf("%sp2", GetFlagPrefix())
    10  Init(fmt.Sprintf("--%s=true", name1), fmt.Sprintf("--%s", name2), "test", fmt.Sprintf("--%s", name3))
    11  
    12  fmt.Println(IsTrue(GetOptWithEnv(name1)))
    13  fmt.Println(GetOptWithEnv(name2))
    14  fmt.Println(IsTrue(GetOptWithEnv(name3)))
    15  ```
    16  
    17  Output:
    18  ```text
    19  true
    20  test
    21  false
    22  ```