本文整理汇总了Golang中flag.PrintDefaults函数的典型用法代码示例。如果您正苦于以下问题:Golang PrintDefaults函数的具体用法?Golang PrintDefaults怎么用?Golang PrintDefaults使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了PrintDefaults函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: main

func main() {
    certpath := flag.String("cert", "", "The path to a PEM certificate")
    keypath := flag.String("key", "", "The path to a PEM key")
    flag.Parse()
    if len(*certpath) == 0 || len(*keypath) == 0 {
        flag.PrintDefaults()
        return
    }
    ctx := gossl.NewContext(gossl.SSLv3Method())
    ctx.SetOptions(gossl.OpNoCompression)
    err := ctx.UsePrivateKeyFile(*keypath, gossl.FileTypePem)
    if err != nil {
        panic(err)
    }
    ctx.UseCertificateFile(*certpath, gossl.FileTypePem)
    if err != nil {
        panic(err)
    }
    l, err := net.Listen("tcp", ":8000")
    if err != nil {
        panic(err)
    }
    l, err = gossl.NewListener(l, ctx)
    http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
        fmt.Fprintf(w, "Hello, %q\n", html.EscapeString(r.URL.Path))
    })
    http.Serve(l, nil)

}

开发者ID:runcom,项目名称:gossl,代码行数:29,代码来源:httpserver.go

示例2: main

func main() {
    detector := flag.Bool("detector", false, "start detector")
    // webapp := flag.Bool("webapp", false, "start webapp")
    // alerter := flag.Bool("alerter", false, "start alerter")
    fileName := flag.String("config", "", "config path")
    version := flag.Bool("version", false, "show version")
    flag.Parse()
    if *version {
        fmt.Fprintln(os.Stderr, VERSION)
        os.Exit(1)
    }
    if flag.NFlag() != 2 {
        flag.PrintDefaults()
        os.Exit(1)
    }
    cfg, err := config.NewWithJsonFile(*fileName)
    if err != nil {
        log.Fatalf("failed to read %s: %v", *fileName, err)
    }
    switch {
    case *detector:
        StartDetector(cfg.Detector)
    default:
        flag.PrintDefaults()
        os.Exit(1)
    }
}

开发者ID:hit9,项目名称:noise.old,代码行数:27,代码来源:main.go

示例3: init

func init() {
    flag.StringVar(&address, "address", "localhost:28015", "The address to connect to a RethinkDB instance.")
    flag.StringVar(&db, "database", "", "The RethinkDB database to use.")
    flag.StringVar(&table, "table", "", "The RethinkDB database table to use.")
    flag.Parse()

    if len(db) == 0 {
        fmt.Println("You must pass the name of a database to use.\n")
        flag.PrintDefaults()
        os.Exit(1)
    }

    if len(table) == 0 {
        fmt.Println("You must pass the name of database table to use.\n")
        flag.PrintDefaults()
        os.Exit(1)
    }

    //session, err := r.Connect(r.ConnectOpts{
    //    Address:  address,
    //    Database: db,
    //    MaxIdle:  10,
    //    MaxOpen:  10,
    //})
    //if err != nil {
    //    log.Fatalln(err.Error())
    //}
}

开发者ID:gabesullice,项目名称:reaper,代码行数:28,代码来源:reaper.go

示例4: main

func main() {
    flag.Parse()
    if len(config_file) > 0 {
        config = NewTunnelConfig(config_file)
        info.Println(config)
    }

    argv := flag.Args()
    argc := len(argv)

    mode := ""
    if argc > 0 {
        mode = argv[argc-1]
    }

    go NewStatServer().serve()
    appevt.Trigger("appmode", mode)

    switch mode {
    case "client":
        if config == nil {
            flag.PrintDefaults()
            os.Exit(-1)
        }
        tc := NewTunnelc()
        tc.serve()
    case "server":
        td := NewTunneld()
        td.serve()
    default:
        log.Println("Invalid mode")
        flag.PrintDefaults()
    }

}

开发者ID:kitech,项目名称:toxsh,代码行数:35,代码来源:main.go

示例5: init

func init() {
    flag.StringVar(&sourceURL, "u", "", "the url you wish to download from")
    flag.StringVar(&remoteFile, "r", "", "the remote filename to download")
    flag.StringVar(&localFile, "o", "", "the output filename")
    flag.IntVar(&timeout, "t", 5, "timeout, in seconds")
    flag.BoolVar(&verbose, "v", false, "verbose")
    flag.BoolVar(&showFiles, "l", false, "list files in zip")
    flag.Uint64Var(&limitBytes, "b", 0, "limit filesize downloaded (in bytes)")

    flag.Parse()

    if sourceURL == "" {
        fmt.Println("You must specify a URL")
        flag.PrintDefaults()
        os.Exit(1)
    }

    if !showFiles {
        if remoteFile == "" {
            fmt.Println("You must specify a remote filename")
            flag.PrintDefaults()
            os.Exit(1)
        }

        if localFile == "" {
            _, localFile = filepath.Split(remoteFile)
        }
    }
}

开发者ID:cj123,项目名称:rover,代码行数:29,代码来源:main.go

最后编辑: kuteng  文档更新时间: 2021-08-23 19:14   作者:kuteng