本文整理汇总了Golang中flag.NArg函数的典型用法代码示例。如果您正苦于以下问题:Golang NArg函数的具体用法?Golang NArg怎么用?Golang NArg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NArg函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
flag.Parse()
if flag.NArg() < 1 {
fmt.Println("Must specify path to a gouchstore compatible file")
return
} else if flag.NArg() < 2 {
fmt.Println("Must specify path to the new compacted gouchstore file")
return
}
var ops gouchstore.GouchOps
if *memCompact {
ops = gouchstore.NewMemCompactGouchOps()
} else {
ops = gouchstore.NewBaseGouchOps()
}
db, err := gouchstore.OpenEx(flag.Args()[0], gouchstore.OPEN_RDONLY, ops)
if err != nil {
fmt.Println(err)
return
}
defer db.Close()
err = db.Compact(flag.Arg(1))
if err != nil {
fmt.Println(err)
}
}
开发者ID:ngaut,项目名称:gouchstore,代码行数:30,代码来源:main.go
示例2: main
func main() {
FILE = os.Stdin
flag.Parse()
versionTxt()
sigChan := make(chan int, 0)
d0 := make(chan chanT, 0)
d1 := make(chan chanT, 0)
c := make(chan string, 30)
f := make(chan io.Reader, 5)
setupSignal(sigChan)
go pr(c, d0)
// As soon as you introduce more than one file, your output
// will get mixed up. How do you fix that?
for i := 0; i < flag.NArg(); i++ {
FILE, _ = Open(flag.Arg(i))
f <- FILE
go read(f, c, d1)
}
if flag.NArg() == 0 {
f <- FILE
go read(f, c, d1)
}
wait(d0, d1, sigChan, flag.NArg())
}
开发者ID:mchirico,项目名称:chirico,代码行数:32,代码来源:main.go
示例3: main
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
var opt optionSet
flag.BoolVar(&opt.v, "V", false, "show version.")
flag.BoolVar(&opt.g, "g", false, "enable grep.")
flag.BoolVar(&opt.search_binary, "search-binary", false, "search binary files for matches on grep enable.")
flag.BoolVar(&opt.grep_only, "grep-only", false, "enable grep and disable file search.")
flag.StringVar(&opt.ignore, "ignore", "", "pattern is ignored.")
flag.BoolVar(&opt.hidden, "hidden", false, "search hidden files.")
flag.BoolVar(&opt.ignorecase, "ignorecase", false, "ignore case distinctions in pattern.")
flag.Parse()
if opt.v {
fmt.Printf("version: %s\n", version)
os.Exit(0)
}
if flag.NArg() < 1 {
usage()
}
pattern := flag.Arg(0)
fpath := "."
if flag.NArg() >= 2 {
fpath = strings.TrimRight(flag.Arg(1), separator)
}
g := newGorep(pattern, &opt)
chans := g.kick(fpath)
g.report(chans, verifyColor())
}
开发者ID:ryochack,项目名称:gorep,代码行数:32,代码来源:gorep.go
示例4: main
func main() {
var pubFile, privFile string
var help, listen, stayOpen bool
flag.BoolVar(&help, "h", false, "display a short usage message")
flag.BoolVar(&stayOpen, "k", false, "keep listening after client disconnects")
flag.BoolVar(&listen, "l", false, "listen for incoming connections")
flag.StringVar(&privFile, "s", "", "path to signature key")
flag.StringVar(&pubFile, "v", "", "path to verification key")
flag.Parse()
if help {
usage()
os.Exit(1)
}
loadID(privFile, pubFile)
defer func() {
if idPriv != nil {
zero(idPriv[:], 0)
}
}()
if listen {
if flag.NArg() != 1 {
fmt.Println("A port is required (and should be the only argument) when listening.")
}
listener(stayOpen, flag.Arg(0))
return
}
if flag.NArg() != 2 {
fmt.Println("An address and port are required (and should be the only arguments).")
}
sender(flag.Arg(0) + ":" + flag.Arg(1))
}
开发者ID:jmptrader,项目名称:go-schannel,代码行数:35,代码来源:nc.go
示例5: main
func main() {
search := flag.String("s", "", "search issues")
create := flag.Bool("C", false, "create issue")
comment := flag.Bool("c", false, "show comments")
flag.Usage = func() {
fmt.Fprint(os.Stderr, "Usage: goissue [-c ID | -s WORD]\n")
flag.PrintDefaults()
}
flag.Parse()
if flag.NArg() > 1 {
flag.Usage()
os.Exit(1)
}
config := getConfig()
auth := authLogin(config)
if *create {
createIssue(auth)
} else if len(*search) > 0 {
searchIssues(auth, *search)
} else if flag.NArg() == 0 {
showIssues(auth)
} else {
for i := 0; i < flag.NArg(); i++ {
showIssue(auth, flag.Arg(i))
if *comment {
showComments(auth, flag.Arg(i))
}
}
}
}
开发者ID:andradeandrey,项目名称:goissue,代码行数:32,代码来源:main.go
最后编辑: kuteng 文档更新时间: 2021-08-23 19:14 作者:kuteng