• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang pflag.Parse函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: main

func main() {
	var token = flag.String("token", "nil", "log token")
	var logfile = flag.String("logfile", "/tmp/foo.txt", "log file to follow")
	var seekInfoOnStart = &tail.SeekInfo{Offset: 0, Whence: os.SEEK_END}

	flag.Parse()

	fmt.Println("using token: ", *token)

	if _, err := os.Stat(*logfile); os.IsNotExist(err) {
		fmt.Printf("no such file or directory: %s\n", *logfile)
		return
	}

	le, err := le_go.Connect(*token) // replace with token
	if err != nil {
		panic(err)
	}

	defer le.Close()
	t, err := tail.TailFile(*logfile, tail.Config{Follow: true, ReOpen: true, Location: seekInfoOnStart, Logger: tail.DiscardingLogger})
	if err == nil {
		for line := range t.Lines {
			le.Println(line.Text)
		}
	}
}
开发者ID:jcftang,项目名称:logentries-go,代码行数:27,代码来源:follower-single-token.go


示例2: processVars

func processVars() {
	flag.String("targetDirs", "", "Local directories  to back up.")
	flag.String("s3Host", "", "S3 host.")
	flag.String("s3AccessKey", "", "S3 access key.")
	flag.String("s3SecretKey", "", "S3 secret key.")
	flag.String("s3BucketName", "", "S3 Bucket Name.")
	flag.Int("remoteWorkerCount", 5, "Number of workers performing actions against S3 host.")
	flag.Bool("dryRun", false, "Flag to indicate that this should be a dry run.")
	flag.Parse()

	viper.BindPFlag("targetDirs", flag.CommandLine.Lookup("targetDirs"))
	viper.BindPFlag("s3Host", flag.CommandLine.Lookup("s3Host"))
	viper.BindPFlag("s3AccessKey", flag.CommandLine.Lookup("s3AccessKey"))
	viper.BindPFlag("s3SecretKey", flag.CommandLine.Lookup("s3SecretKey"))
	viper.BindPFlag("s3BucketName", flag.CommandLine.Lookup("s3BucketName"))
	viper.BindPFlag("remoteWorkerCount", flag.CommandLine.Lookup("remoteWorkerCount"))
	viper.BindPFlag("dryRun", flag.CommandLine.Lookup("dryRun"))

	viper.AutomaticEnv()
	viper.SetEnvPrefix("PERSONAL_BACKUP")
	viper.BindEnv("targetDirs")
	viper.BindEnv("s3Host")
	viper.BindEnv("s3AccessKey")
	viper.BindEnv("s3SecretKey")
	viper.BindEnv("s3BucketName")
	viper.BindEnv("remoteWorkerCount")

	viper.SetDefault("remoteWorkerCount", 5)
}
开发者ID:ptrimble,项目名称:dreamhost-personal-backup,代码行数:29,代码来源:main.go


示例3: main

func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())
	flag.Parse()

	var out io.Writer
	if *outputDest == "-" {
		out = os.Stdout
	} else {
		file, err := os.Create(*outputDest)
		if err != nil {
			glog.Fatalf("Couldn't open %v: %v", *outputDest, err)
		}
		defer file.Close()
		out = file
	}

	versionsForConversion := strings.Split(*versions, ",")
	for _, version := range versionsForConversion {
		generator := conversion.NewGenerator(api.Scheme.Raw())
		// TODO(wojtek-t): Change the overwrites to a flag.
		generator.OverwritePackage(version, "")
		generator.OverwritePackage("api", "newer")
		for _, knownType := range api.Scheme.KnownTypes(version) {
			if err := generator.GenerateConversionsForType(version, knownType); err != nil {
				glog.Errorf("error while generating conversion functions for %v: %v", knownType, err)
			}
		}
		if err := generator.WriteConversionFunctions(out); err != nil {
			glog.Fatalf("Error while writing conversion functions: %v", err)
		}
	}
}
开发者ID:SivagnanamCiena,项目名称:calico-kubernetes,代码行数:32,代码来源:conversion.go


示例4: main

func main() {
	log.SetLevel(log.FatalLevel)

	var coordinator, responseAddr, taskName string
	var taskArgs []string
	flags.StringVarP(&coordinator, "coordinator_url", "c", "", "url of the coordinator")
	flags.StringVarP(&taskName, "task", "t", "", "task to run")
	flags.StringSliceVarP(&taskArgs, "request_arg", "a", []string{}, fmt.Sprintf("task specific argument the form 'key%svalue'. can be set multiple times", argSep))
	flags.StringVarP(&responseAddr, "response_addr", "r", ":4080", "address for response http handler to listen on")
	flags.Parse()

	args, err := parseTaskArgs(taskArgs)
	dieOnError(err)

	result, stream, respErr, err := startResponseServer(responseAddr)
	dieOnError(err)

	dieOnError(makeRequest(coordinator, taskName, responseAddr, args))

	select {
	case err := <-respErr:
		dieOnError(err)
	case result := <-result:
		j, _ := json.Marshal(result)
		fmt.Println(string(j))
	case stream := <-stream:
		dieOnError(acomm.Stream(os.Stdout, stream))
	}
}
开发者ID:mistifyio,项目名称:coordinator,代码行数:29,代码来源:main.go


示例5: main

func main() {
	arguments := args.Default()
	flag.Parse()
	dependencies := []string{
		"k8s.io/kubernetes/pkg/fields",
		"k8s.io/kubernetes/pkg/labels",
		"k8s.io/kubernetes/pkg/watch",
		"k8s.io/kubernetes/pkg/client/unversioned",
		"k8s.io/kubernetes/pkg/client/testing/fake",
		"k8s.io/kubernetes/pkg/apimachinery/registered",
	}

	if *test {
		arguments.InputDirs = append(dependencies, []string{
			"k8s.io/kubernetes/cmd/libs/go2idl/client-gen/testdata/apis/testgroup",
		}...)
		// We may change the output path later.
		arguments.OutputPackagePath = "k8s.io/kubernetes/cmd/libs/go2idl/client-gen/testoutput"
		arguments.CustomArgs = generators.ClientGenArgs{
			[]unversioned.GroupVersion{{"testgroup", ""}},
			map[unversioned.GroupVersion]string{
				unversioned.GroupVersion{"testgroup", ""}: "k8s.io/kubernetes/cmd/libs/go2idl/client-gen/testdata/apis/testgroup",
			},
			"test_internalclientset",
			"k8s.io/kubernetes/cmd/libs/go2idl/client-gen/testoutput/clientset_generated/",
			false,
			false,
		}
	} else {
		inputPath, groupVersions, gvToPath, err := parseInputVersions()
		if err != nil {
			glog.Fatalf("Error: %v", err)
		}
		glog.Infof("going to generate clientset from these input paths: %v", inputPath)
		arguments.InputDirs = append(inputPath, dependencies...)
		// TODO: we need to make OutPackagePath a map[string]string. For example,
		// we need clientset and the individual typed clients be output to different
		// output path.

		// We may change the output path later.
		arguments.OutputPackagePath = "k8s.io/kubernetes/pkg/client/typed/generated"

		arguments.CustomArgs = generators.ClientGenArgs{
			groupVersions,
			gvToPath,
			*clientsetName,
			*clientsetPath,
			*clientsetOnly,
			*fakeClient,
		}
	}

	if err := arguments.Execute(
		generators.NameSystems(),
		generators.DefaultNameSystem(),
		generators.Packages,
	); err != nil {
		glog.Fatalf("Error: %v", err)
	}
}
开发者ID:richm,项目名称:origin,代码行数:60,代码来源:main.go


示例6: Setup

func Setup() {
	flag.Parse()

	AppSettings.BindPFlag("port", flag.Lookup("port"))
	AppSettings.BindPFlag("address", flag.Lookup("bind"))
	AppSettings.BindPFlag("config", flag.Lookup("config"))
	AppSettings.BindPFlag("env", flag.Lookup("env"))
	S3Settings.BindPFlag("env", flag.Lookup("env"))

	AppSettings.SetDefault("address", "0.0.0.0")
	AppSettings.SetDefault("port", "5000")
	AppSettings.SetDefault("env", "development")
	AppSettings.SetDefault("config", "./config.yml")
	S3Settings.SetDefault("env", "development")

	configPath := filepath.Dir(AppSettings.GetString("config"))
	configName := strings.Replace(filepath.Base(AppSettings.GetString("config")), filepath.Ext(AppSettings.GetString("config")), "", -1)

	AppSettings.SetConfigName(configName)
	AppSettings.AddConfigPath(configPath)

	err := AppSettings.ReadInConfig()
	if err != nil {
		log.Fatal(fmt.Errorf("Fatal error config file: %s \n", err))
	}

	S3Settings.SetConfigName("s3")
	S3Settings.AddConfigPath("./")

	err = S3Settings.ReadInConfig()
	if err != nil {
		log.Fatal(fmt.Errorf("Fatal error config file: %s \n", err))
	}
}
开发者ID:Arimeka,项目名称:static-proxy,代码行数:34,代码来源:settings.go


示例7: main

func main() {
	// Set logging output to standard console out
	log.SetOutput(os.Stdout)

	pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
	pflag.Parse()
	flag.CommandLine.Parse(make([]string, 0)) // Init for glog calls in kubernetes packages

	log.Printf("Starting HTTP server on port %d", *argPort)

	apiserverClient, config, err := CreateApiserverClient(*argApiserverHost)
	if err != nil {
		handleFatalInitError(err)
	}

	versionInfo, err := apiserverClient.ServerVersion()
	if err != nil {
		handleFatalInitError(err)
	}
	log.Printf("Successful initial request to the apiserver, version: %s", versionInfo.String())

	heapsterRESTClient, err := CreateHeapsterRESTClient(*argHeapsterHost, apiserverClient)
	if err != nil {
		log.Printf("Could not create heapster client: %s. Continuing.", err)
	}

	// Run a HTTP server that serves static public files from './public' and handles API calls.
	// TODO(bryk): Disable directory listing.
	http.Handle("/", MakeGzipHandler(CreateLocaleHandler()))
	http.Handle("/api/", CreateHttpApiHandler(apiserverClient, heapsterRESTClient, config))
	// TODO(maciaszczykm): Move to /appConfig.json as it was discussed in #640.
	http.Handle("/api/appConfig.json", AppHandler(ConfigHandler))
	log.Print(http.ListenAndServe(fmt.Sprintf(":%d", *argPort), nil))
}
开发者ID:taimir,项目名称:dashboard,代码行数:34,代码来源:dashboard.go


示例8: main

func main() {
	m := app.NewNetworkManager()
	flag.CommandLine.AddGoFlagSet(goflag.CommandLine)
	m.AddFlags(flag.CommandLine)
	flag.Parse()
	m.Run(flag.CommandLine.Args())
}
开发者ID:pupapaik,项目名称:contrail-kubernetes,代码行数:7,代码来源:manager.go


示例9: init

func init() {
	c := viper.New()

	c.SetEnvPrefix("Q")
	c.AutomaticEnv()

	flag.StringVar(&configFile, "config", "", "")
	flag.Parse()
	c.BindPFlag("config", flag.Lookup("config"))

	if c.GetString("config") == "" {
		// Read from "default" configuration path
		c.SetConfigName("config")
		c.AddConfigPath("/etc/qurid")
		c.AddConfigPath("$HOME/.quarid")
		c.AddConfigPath(".")
	} else {
		c.SetConfigFile(c.GetString("config"))
	}

	if err := c.ReadInConfig(); err != nil {
		panic(fmt.Errorf("Unable to read any configuration file: %s\n", err))
	}

	location, err := time.LoadLocation(c.GetString("timezone"))
	if err == nil {
		c.Set("timezone", location)
	} else {
		c.Set("timezone", time.UTC)
	}

	config = c
}
开发者ID:LiranCohen,项目名称:quarid-go,代码行数:33,代码来源:config.go


示例10: main

func main() {
	pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
	pflag.Parse()

	log.Printf("Starting HTTP server on port %d", *argPort)

	apiserverClient, config, err := CreateApiserverClient(*argApiserverHost)
	if err != nil {
		handleFatalInitError(err)
	}

	versionInfo, err := apiserverClient.ServerVersion()
	if err != nil {
		handleFatalInitError(err)
	}
	log.Printf("Successful initial request to the apiserver, version: %s", versionInfo.String())

	heapsterRESTClient, err := CreateHeapsterRESTClient(*argHeapsterHost, apiserverClient)
	if err != nil {
		log.Print("Could not create heapster client: %s. Continuing.", err)
	}

	// Run a HTTP server that serves static public files from './public' and handles API calls.
	// TODO(bryk): Disable directory listing.
	http.Handle("/", http.FileServer(http.Dir("./public")))
	http.Handle("/api/", CreateHttpApiHandler(apiserverClient, heapsterRESTClient, config))
	// TODO(maciaszczykm): Move to /appConfig.json as it was discussed in #640.
	http.Handle("/api/appConfig.json", AppHandler(configHandler))
	log.Print(http.ListenAndServe(fmt.Sprintf(":%d", *argPort), nil))
}
开发者ID:batikanu,项目名称:dashboard,代码行数:30,代码来源:dashboard.go


示例11: AddFlags

// AddFlags adds flags for a specific LocalkubeServer
func AddFlags(s *localkube.LocalkubeServer) {
	flag.BoolVar(&s.Containerized, "containerized", s.Containerized, "If kubelet should run in containerized mode")
	flag.BoolVar(&s.EnableDNS, "enable-dns", s.EnableDNS, "If dns should be enabled")
	flag.StringVar(&s.DNSDomain, "dns-domain", s.DNSDomain, "The cluster dns domain")
	flag.IPVar(&s.DNSIP, "dns-ip", s.DNSIP, "The cluster dns IP")
	flag.StringVar(&s.LocalkubeDirectory, "localkube-directory", s.LocalkubeDirectory, "The directory localkube will store files in")
	flag.IPNetVar(&s.ServiceClusterIPRange, "service-cluster-ip-range", s.ServiceClusterIPRange, "The service-cluster-ip-range for the apiserver")
	flag.IPVar(&s.APIServerAddress, "apiserver-address", s.APIServerAddress, "The address the apiserver will listen securely on")
	flag.IntVar(&s.APIServerPort, "apiserver-port", s.APIServerPort, "The port the apiserver will listen securely on")
	flag.IPVar(&s.APIServerInsecureAddress, "apiserver-insecure-address", s.APIServerInsecureAddress, "The address the apiserver will listen insecurely on")
	flag.IntVar(&s.APIServerInsecurePort, "apiserver-insecure-port", s.APIServerInsecurePort, "The port the apiserver will listen insecurely on")
	flag.BoolVar(&s.ShouldGenerateCerts, "generate-certs", s.ShouldGenerateCerts, "If localkube should generate it's own certificates")
	flag.BoolVar(&s.ShowVersion, "version", s.ShowVersion, "If localkube should just print the version and exit.")
	flag.Var(&s.RuntimeConfig, "runtime-config", "A set of key=value pairs that describe runtime configuration that may be passed to apiserver. apis/<groupVersion> key can be used to turn on/off specific api versions. apis/<groupVersion>/<resource> can be used to turn on/off specific resources. api/all and api/legacy are special keys to control all and legacy api versions respectively.")
	flag.IPVar(&s.NodeIP, "node-ip", s.NodeIP, "IP address of the node. If set, kubelet will use this IP address for the node.")
	flag.StringVar(&s.ContainerRuntime, "container-runtime", "", "The container runtime to be used")
	flag.StringVar(&s.NetworkPlugin, "network-plugin", "", "The name of the network plugin")

	// These two come from vendor/ packages that use flags. We should hide them
	flag.CommandLine.MarkHidden("google-json-key")
	flag.CommandLine.MarkHidden("log-flush-frequency")

	// Parse them
	flag.Parse()
}
开发者ID:rawlingsj,项目名称:gofabric8,代码行数:26,代码来源:options.go


示例12: main

func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())
	flag.Parse()

	var funcOut io.Writer
	if *functionDest == "-" {
		funcOut = os.Stdout
	} else {
		file, err := os.Create(*functionDest)
		if err != nil {
			glog.Fatalf("Couldn't open %v: %v", *functionDest, err)
		}
		defer file.Close()
		funcOut = file
	}

	generator := pkg_runtime.NewConversionGenerator(api.Scheme.Raw())
	// TODO(wojtek-t): Change the overwrites to a flag.
	generator.OverwritePackage(*version, "")
	for _, knownType := range api.Scheme.KnownTypes(*version) {
		if err := generator.GenerateConversionsForType(*version, knownType); err != nil {
			glog.Errorf("error while generating conversion functions for %v: %v", knownType, err)
		}
	}
	if err := generator.WriteConversionFunctions(funcOut); err != nil {
		glog.Fatalf("Error while writing conversion functions: %v", err)
	}
	if err := generator.RegisterConversionFunctions(funcOut); err != nil {
		glog.Fatalf("Error while writing conversion functions: %v", err)
	}
}
开发者ID:chenzhen411,项目名称:kubernetes,代码行数:31,代码来源:conversion.go


示例13: TestE2eNode

func TestE2eNode(t *testing.T) {
	pflag.Parse()
	if *runServicesMode {
		// If run-services-mode is specified, only run services in current process.
		services.RunE2EServices()
		return
	}
	// If run-services-mode is not specified, run test.
	rand.Seed(time.Now().UTC().UnixNano())
	RegisterFailHandler(Fail)
	reporters := []Reporter{}
	reportDir := framework.TestContext.ReportDir
	if reportDir != "" {
		// Create the directory if it doesn't already exists
		if err := os.MkdirAll(reportDir, 0755); err != nil {
			glog.Errorf("Failed creating report directory: %v", err)
		} else {
			// Configure a junit reporter to write to the directory
			junitFile := fmt.Sprintf("junit_%s%02d.xml", framework.TestContext.ReportPrefix, config.GinkgoConfig.ParallelNode)
			junitPath := path.Join(reportDir, junitFile)
			reporters = append(reporters, more_reporters.NewJUnitReporter(junitPath))
		}
	}
	RunSpecsWithDefaultAndCustomReporters(t, "E2eNode Suite", reporters)
}
开发者ID:PeterLamar,项目名称:kubernetes,代码行数:25,代码来源:e2e_node_suite_test.go


示例14: main

func main() {
	flag.Parse()
	if *version {
		fmt.Printf("rabbit-herder %s\n", Version)
		os.Exit(0)
	}

	apiHosts := herd.GetApiHosts(*apiPtr, *userPtr, *passwordPtr)
	if len(apiHosts) > 1 {
		fmt.Printf(
			"API responded len(%d) with hosts: %s\n",
			len(apiHosts),
			strings.Trim(fmt.Sprint(apiHosts), "[]"),
		)
		fmt.Println("Already in a cluster!")
		os.Exit(0)
	}

	ec2Hosts := herd.GetOtherHosts()
	if len(ec2Hosts) == 0 {
		fmt.Println("No hosts to join!")
	} else {
		fmt.Printf("Joining hosts: %s\n", ec2Hosts)
		herd.JoinCluster(ec2Hosts, *dryRunP)
	}
}
开发者ID:micahhausler,项目名称:rabbit-herder,代码行数:26,代码来源:main.go


示例15: main

func main() {
	flag.CommandLine.SetNormalizeFunc(util.WarnWordSepNormalizeFunc)
	flag.Parse()
	var err error
	// TODO: Validate input flags.
	domain := *argDomain
	if !strings.HasSuffix(domain, ".") {
		domain = fmt.Sprintf("%s.", domain)
	}
	ks := kube2sky{
		domain:              domain,
		etcdMutationTimeout: *argEtcdMutationTimeout,
	}
	if ks.etcdClient, err = newEtcdClient(*argEtcdServer); err != nil {
		glog.Fatalf("Failed to create etcd client - %v", err)
	}

	kubeClient, err := newKubeClient()
	if err != nil {
		glog.Fatalf("Failed to create a kubernetes client: %v", err)
	}

	ks.endpointsStore = watchEndpoints(kubeClient, &ks)
	ks.servicesStore = watchForServices(kubeClient, &ks)
	ks.podsStore = watchPods(kubeClient, &ks)

	select {}
}
开发者ID:vjsamuel,项目名称:kubernetes,代码行数:28,代码来源:kube2sky.go


示例16: main

func main() {
	pflag.Parse()

	p2p.PrintMessages(printNetworkMessages)

	log.SetPrefix(p2pConfig.Name + " ")

	network := p2p.New(p2pConfig)
	network.Join(pflag.Args())

	cfg := libsyncer.Config{
		FileServerConfig: fsConfig,
		PriceFormula:     pricer(),
		Transport:        network,
		Volume:           volume(),
	}
	syncer := libsyncer.New(cfg)
	go syncer.Serve()

	ch := make(chan os.Signal)
	signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM)
	<-ch

	log.Println("Received shutdown signal. Stopping ...")
	syncer.Stop()

	if err := network.Leave(10 * time.Second); err != nil {
		log.Printf("ERROR: %v", err)
	}
}
开发者ID:zeisss,项目名称:mediasyncer,代码行数:30,代码来源:mediasyncer.go


示例17: main

func main() {
	flag.Parse()

	if *fSymbol == "" {
		fmt.Println("Symbol is required: GOOG, AAPL")
		return
	}

	params := network.Params{
		Symbol:    strings.ToUpper(*fSymbol),
		StartDate: network.DateComponentsFromString(*fStartDate),
		EndDate:   network.DateComponentsFromString(*fEndDate),
	}

	fmt.Printf("Fetching: %s %s-%s\n", params.Symbol, params.StartDate, params.EndDate)

	stock, err := network.FetchStockData(params)
	if err != nil {
		fmt.Println("Unable to fetch stock:", err)
		fmt.Println("args:", fSymbol, fStartDate, *fEndDate)
		return
	}

	fmt.Println(stock)
}
开发者ID:cbess,项目名称:stockfetch,代码行数:25,代码来源:main.go


示例18: main

func main() {
	pflag.Parse()

	viper.SetConfigName("config")
	viper.AddConfigPath(".")

	if debug {
		logrus.SetLevel(logrus.DebugLevel)
	}

	if err := viper.ReadInConfig(); err != nil {
		logrus.Fatal(err)
	}

	nick := viper.GetString("twitch.nick")
	pass := viper.GetString("twitch.pass")
	channels := viper.GetStringSlice("twitch.join")
	dbFilename := viper.GetString("database.filename")
	superusers := viper.GetStringSlice("permissions.superusers")

	bot := bot.NewBot(nick, pass, channels, dbFilename, superusers)
	if err := bot.Start(); err != nil {
		logrus.Fatal(err)
	}

	c := make(chan os.Signal, 1)
	signal.Notify(c, os.Interrupt)
	<-c
	fmt.Print("\r\r\b")

	if err := bot.Stop(); err != nil {
		logrus.Fatal(err)
	}
}
开发者ID:jakebailey,项目名称:botzik,代码行数:34,代码来源:main.go


示例19: realMain

func realMain() error {

	flag.StringSliceVarP(&configFiles, "file", "f", nil, "file")
	flag.BoolVar(&jsonOut, "json", false, "")
	flag.BoolVarP(&versionFlag, "version", "v", false, "")

	flag.Parse()

	if jsonOut {
		logrus.SetFormatter(&logrus.JSONFormatter{})
	}

	if versionFlag {
		fmt.Printf("gcron version %s\n", VERSION)
		os.Exit(0)
	}

	c := internal.NewCron()

	if len(configFiles) == 0 {
		return errors.New("No cronfiles")
	}

	if err := loadFiles(c); err != nil {
		return err
	}

	c.Start()

	return listen(c)
}
开发者ID:kildevaeld,项目名称:gcron,代码行数:31,代码来源:main.go


示例20: main

func main() {
	pflag.CommandLine.AddGoFlagSet(flag.CommandLine)

	pflag.Parse()
	glog.Info("Starting HTTP server on port ", *argPort)
	defer glog.Flush()

	apiserverClient, err := CreateApiserverClient(*argApiserverHost, new(ClientFactoryImpl))
	if err != nil {
		glog.Fatal(err)
	}

	serverAPIVersion, err := apiserverClient.ServerAPIVersions()
	if err != nil {
		glog.Fatal(err)
	}

	// Display Apiserver version. This is just for tests.
	println("Server API version: " + serverAPIVersion.GoString())

	// Run a HTTP server that serves static public files from './public' and handles API calls.
	// TODO(bryk): Disable directory listing.
	http.Handle("/", http.FileServer(http.Dir("./public")))
	http.Handle("/api/", CreateHttpApiHandler(apiserverClient))
	glog.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", *argPort), nil))
}
开发者ID:bcbroussard,项目名称:dashboard,代码行数:26,代码来源:dashboard.go



注:本文中的github.com/spf13/pflag.Parse函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang pflag.String函数代码示例发布时间:2022-05-28
下一篇:
Golang pflag.NormalizedName函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap