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

Golang config.ReadConfigFile函数代码示例

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

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



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

示例1: init

func init() {
	config.ReadConfigFile("settings.yaml")
	//TODO: Error Checking
	basePath, _ := config.GetString("TEMPLATES:BASE")
	layoutsPath, _ := config.GetString("TEMPLATES:LAYOUTS")
	partialsPath, _ := config.GetString("TEMPLATES:PARTIALS")

	dir, _ := os.Getwd()
	templatesPath = filepath.Join(dir, basePath)
	fmt.Printf("Processing templates in %s\n", templatesPath)

	if templates == nil {
		templates = make(map[string]*template.Template)
	}

	layouts, err := filepath.Glob(templatesPath + "/" + layoutsPath + "/*")
	if err != nil {
		log.Fatal(err)
	}

	partials, err := filepath.Glob(templatesPath + "/" + partialsPath + "/*")
	if err != nil {
		log.Fatal(err)
	}

	for _, layout := range layouts {
		files := append(partials, layout)
		templates[filepath.Base(layout)] = template.Must(template.ParseFiles(files...))
	}

	UserRepo = user.NewBaseUserRepository()
	if _, err := UserRepo.NewUser("jeff", "password"); err != nil {
		fmt.Println(err)
	}
}
开发者ID:archeious,项目名称:ARES,代码行数:35,代码来源:main.go


示例2: main

func main() {
	var err error
	log, err = syslog.New(syslog.LOG_INFO, "gandalf-listener")
	if err != nil {
		fmt.Fprintln(os.Stderr, err.Error())
		panic(err.Error())
	}
	err = config.ReadConfigFile("/etc/gandalf.conf")
	if err != nil {
		log.Err(err.Error())
		fmt.Fprintln(os.Stderr, err.Error())
		return
	}
	_, _, err = parseGitCommand()
	if err != nil {
		log.Err(err.Error())
		fmt.Fprintln(os.Stderr, err.Error())
		return
	}
	a := action()
	if a == "git-receive-pack" {
		executeAction(hasWritePermission, "You don't have access to write in this repository.", os.Stdout)
		return
	}
	if a == "git-upload-pack" {
		executeAction(hasReadPermission, "You don't have access to read this repository.", os.Stdout)
		return
	}
}
开发者ID:ricardodani,项目名称:gandalf,代码行数:29,代码来源:gandalf.go


示例3: SetUpSuite

func (s *S) SetUpSuite(c *check.C) {
	err := config.ReadConfigFile("testdata/config.yaml")
	c.Assert(err, check.IsNil)
	config.Set("database:url", "127.0.0.1:27017")
	config.Set("database:name", "tsuru_api_base_test")
	app.LogPubSubQueuePrefix = "pubsub:api-base-test:"
}
开发者ID:pedrosnk,项目名称:tsuru,代码行数:7,代码来源:suite_test.go


示例4: SetUpTest

func (s *S) SetUpTest(c *check.C) {
	config.ReadConfigFile("testdata/tsuru.conf")
	conn, err := db.Conn()
	c.Assert(err, check.IsNil)
	defer conn.Close()
	dbtest.ClearAllCollections(conn.Apps().Database)
	repositorytest.Reset()
}
开发者ID:zhenruyan,项目名称:tsuru,代码行数:8,代码来源:suite_test.go


示例5: Set

func (v *configFile) Set(value string) error {
	err := config.ReadConfigFile(value)
	if err != nil {
		return err
	}
	v.value = value
	return nil
}
开发者ID:WIZARD-CXY,项目名称:golang-devops-stuff,代码行数:8,代码来源:command.go


示例6: SetUpSuite

func (s *S) SetUpSuite(c *gocheck.C) {
	err := config.ReadConfigFile("../etc/gandalf.conf")
	c.Assert(err, gocheck.IsNil)
	config.Set("database:url", "127.0.0.1:27017")
	config.Set("database:name", "gandalf_api_tests")
	s.tmpdir, err = commandmocker.Add("git", "")
	c.Assert(err, gocheck.IsNil)
}
开发者ID:heynemann,项目名称:gandalf,代码行数:8,代码来源:utils_test.go


示例7: main

func main() {
	p, _ := filepath.Abs(defaultConfigPath)
	log.Println(fmt.Errorf("Conf: %s", p))
	config.ReadConfigFile(defaultConfigPath)
	name := cmd.ExtractProgramName(os.Args[0])
	manager := buildManager(name)
	manager.Run(os.Args[1:])
}
开发者ID:rajthilakmca,项目名称:megamgulp,代码行数:8,代码来源:main.go


示例8: FlagResolve

func FlagResolve(localAddr *string, serverAddr *string, username *string, password *string) {
	flag.Parse()

	if *helpFlag != false {
		//log.Log("info", "", nil)
		fmt.Println("Usage:...........!!!!!")
		os.Exit(0)
	}
	if *versionFlag != false {
		err := config.ReadConfigFile("../client/config/version.yml")
		if err != nil {
			fmt.Println(err)
			os.Exit(0)
		}
		version, _ := config.GetString("version")
		update, _ := config.GetList("update")
		instruction, _ := config.GetString("instruction")
		fmt.Printf("CaeserClient version: %s\n", version)
		fmt.Printf("New speciality contrast to old version: \n")
		for k, v := range update {
			fmt.Printf("%d-- %s\n", k+1, v)
		}
		fmt.Printf("       %s\n", instruction)
		os.Exit(0)
	}
	if *localFlag != "" {
		*localAddr = *localFlag
		log.Log("info", "you set a new addres", log.Fields{"address": *localFlag})
		//fmt.Println("--Notice: you have set a new address", *localAddr)
	} else {
		//fmt.Println("--Didn't set the start port. Caesar will start at default port.")
		log.Log("info", "Didn't set the start port. Caesar will start at default port.", log.Fields{"default address": *localAddr})
	}
	if *serverFlag != "" {
		fp, err := regexp.MatchString(ipPattern, *serverFlag)
		handleError(err)
		if !fp {
			//fmt.Printf("\"%s\" is not a valid address, please check it and try again!\n", *serverFlag)
			warnMsg := *serverFlag + "is not a valid address, please check it and try again!"
			log.Log("warn", warnMsg, nil)
			os.Exit(0)
		}
		*serverAddr = *serverFlag
		log.Log("info", "You have set a new server address", log.Fields{"new address": *serverAddr})
		//fmt.Println("--Notice: you have set a new server address", *serverAddr)
	} else {
		log.Log("info", "Didn't set the server address.Caesar will connect the default address.", log.Fields{"new address": *serverAddr})
		//fmt.Println("--Didn't set the server address. Caesar will connect the default address.")
	}
	if *userFlag != "" && *passwordFlag != "" {
		*username = *userFlag
		*password = *passwordFlag
		fmt.Println(*username, *password)
	} else {
		//fmt.Println("--Anonymous login, can do nothing! Please login with exgist user or register a new user.")
		log.Log("info", "Anonymous login, can do nothing! Please login with exgist user or register a new user.", nil)
	}
}
开发者ID:jmptrader,项目名称:Caesar,代码行数:58,代码来源:cflag.go


示例9: listenSignals

func listenSignals() {
	ch := make(chan os.Signal, 1)
	signal.Notify(ch, syscall.SIGHUP)
	go func() {
		for range ch {
			config.ReadConfigFile(configPath)
		}
	}()
}
开发者ID:zhenruyan,项目名称:tsuru,代码行数:9,代码来源:main.go


示例10: SetUpSuite

func (s *S) SetUpSuite(c *gocheck.C) {
	err := config.ReadConfigFile("testdata/config.yaml")
	s.conn, err = db.Conn()
	c.Assert(err, gocheck.IsNil)
	s.createUserAndTeam(c)
	s.t = &tsuruTesting.T{}
	s.provisioner = tsuruTesting.NewFakeProvisioner()
	app.Provisioner = s.provisioner
	p := app.Platform{Name: "zend"}
	s.conn.Platforms().Insert(p)
}
开发者ID:royalwang,项目名称:tsuru,代码行数:11,代码来源:suite_test.go


示例11: init

func init() {
	err := config.ReadConfigFile("../config/msgserver.yaml")
	if err != nil {
		//fmt.Print(err)
		mylog.Log("err", err.Error(), nil)
	} else {
		mylog.Log("info", "Message server config read!", nil)
	}
	ListenPort, err = config.GetString("listenport")
	handleErr(err)
}
开发者ID:jmptrader,项目名称:Caesar,代码行数:11,代码来源:msgServer.go


示例12: readConfig

func readConfig(path string) (Config, error) {
	cfg := Config{}
	configFile := filepath.Join(path, "config.yaml")

	err := config.ReadConfigFile(configFile)
	if err != nil {
		return cfg, err
	}

	cfg.Id, err = config.GetString("id")
	if err != nil {
		return cfg, err
	}

	cfg.Hostname, err = config.GetString("hostname")
	if err != nil {
		return cfg, err
	}

	cfg.DiskPath = filepath.Join(path, "disk.qcow")
	cfg.Disk, err = config.GetInt("disk")
	if err != nil {
		return cfg, err
	}

	cfg.Cpu, err = config.GetInt("cpu")
	if err != nil {
		return cfg, err
	}

	cfg.Memory, err = config.GetInt("memory")
	if err != nil {
		return cfg, err
	}

	cfg.DNS, err = config.GetString("dns")
	if err != nil {
		return cfg, err
	}

	cfg.Docker, err = config.GetString("docker")
	if err != nil {
		return cfg, err
	}

	cfg.Extra, err = config.GetString("extra")
	if err != nil {
		return cfg, err
	}

	cfg.Route, err = config.GetBool("route")
	return cfg, err
}
开发者ID:nlf,项目名称:dlite,代码行数:53,代码来源:config.go


示例13: Readconfig

//Read the config file and set the config.
func Readconfig(local *string, server *string) {
	err := config.ReadConfigFile("../client/config/client.yml")
	handleError(err)

	*local, err = config.GetString("localaddress")
	handleError(err)

	*server, err = config.GetString("serveraddress")

	handleError(err)

}
开发者ID:jmptrader,项目名称:Caesar,代码行数:13,代码来源:serverRpc.go


示例14: SetUpSuite

func (s *EventSuite) SetUpSuite(c *check.C) {
	err := config.ReadConfigFile("testdata/config.yaml")
	c.Assert(err, check.IsNil)
	config.Set("database:url", "127.0.0.1:27017")
	config.Set("database:name", "tsuru_events_api_tests")
	config.Set("auth:hash-cost", 4)
	config.Set("repo-manager", "fake")
	s.conn, err = db.Conn()
	c.Assert(err, check.IsNil)
	s.logConn, err = db.LogConn()
	c.Assert(err, check.IsNil)
}
开发者ID:tsuru,项目名称:tsuru,代码行数:12,代码来源:event_test.go


示例15: SetUpSuite

func (s *S) SetUpSuite(c *gocheck.C) {
	err := config.ReadConfigFile("testdata/config.yaml")
	c.Assert(err, gocheck.IsNil)
	s.conn, err = db.Conn()
	c.Assert(err, gocheck.IsNil)
	s.t = &ttesting.T{}
	s.createUserAndTeam(c)
	s.t.SetGitConfs(c)
	s.provisioner = ttesting.NewFakeProvisioner()
	Provisioner = s.provisioner
	platform := Platform{Name: "python"}
	s.conn.Platforms().Insert(platform)
}
开发者ID:renanoliveira,项目名称:tsuru,代码行数:13,代码来源:suite_test.go


示例16: listenSignals

func listenSignals() {
	ch := make(chan os.Signal, 2)
	go func() {
		for sig := range ch {
			switch sig {
			case syscall.SIGUSR1:
				pprof.Lookup("goroutine").WriteTo(os.Stdout, 2)
			case syscall.SIGHUP:
				config.ReadConfigFile(configPath)
			}
		}
	}()
	signal.Notify(ch, syscall.SIGHUP, syscall.SIGUSR1)
}
开发者ID:pedrosnk,项目名称:tsuru,代码行数:14,代码来源:main.go


示例17: Run

func (c *tsrCommand) Run(context *cmd.Context, client *cmd.Client) error {
	fmt.Fprintf(context.Stderr, "Opening config file: %s\n", configPath)
	err := config.ReadConfigFile(configPath)
	if err != nil {
		msg := `Could not open tsuru config file at %s (%s).
  For an example, see: tsuru/etc/tsuru.conf
  Note that you can specify a different config file with the --config option -- e.g.: --config=./etc/tsuru.conf
`
		fmt.Fprintf(context.Stderr, msg, configPath, err)
		return err
	}
	fmt.Fprintf(context.Stderr, "Done reading config file: %s\n", configPath)
	return c.Command.Run(context, client)
}
开发者ID:RichardKnop,项目名称:tsuru,代码行数:14,代码来源:command.go


示例18: loadConf

//Load configuration file.
func loadConf() {
	log.Log("info", "Load config file...", nil)
	err := config.ReadConfigFile("../config/server.yaml")
	if err != nil {
		//fmt.Print(err)
		log.Log("err", err.Error(), nil)
	} else {
		log.Log("info", "Completely read!", nil)
	}

	listenAddr, err = config.GetString("rpcAddress")
	handleErr(err)
	msgAddr, err = config.GetString("msgAddress")
	handleErr(err)
}
开发者ID:jmptrader,项目名称:Caesar,代码行数:16,代码来源:CaesarServer.go


示例19: SetUpSuite

func (s *S) SetUpSuite(c *check.C) {
	err := config.ReadConfigFile("testdata/config.yaml")
	c.Assert(err, check.IsNil)
	s.conn, err = db.Conn()
	c.Assert(err, check.IsNil)
	s.logConn, err = db.LogConn()
	c.Assert(err, check.IsNil)
	s.provisioner = provisiontest.NewFakeProvisioner()
	Provisioner = s.provisioner
	AuthScheme = nativeScheme
	data, err := json.Marshal(AppLock{})
	c.Assert(err, check.IsNil)
	err = json.Unmarshal(data, &s.zeroLock)
	c.Assert(err, check.IsNil)
}
开发者ID:RichardKnop,项目名称:tsuru,代码行数:15,代码来源:suite_test.go


示例20: configDaemon

func configDaemon(imp, file string) {
	var watchers []*fsnotify.Watcher

	// closeWatchers is iterating over available watchers
	// and closes them.
	closeWatchers := func() {
		for i := range watchers {
			watchers[i].Close()
		}
		watchers = []*fsnotify.Watcher{}
	}
	defer closeWatchers() // Close watchers when we are done.

	for {
		// Wait till we are asked to reload the config file.
		<-restart

		// Closing old watchers to create new ones.
		closeWatchers()

		// Trying to read a configuration file..
		err := config.ReadConfigFile(file)
		if err != nil {
			log.Error.Printf(
				`Are you sure "%s" is a path of goal project?
"%s" file is missing.`, imp, file,
			)
			notify <- syscall.SIGTERM
			return
		}

		// Parsing configuration file and extracting the values
		// we need.
		log.Trace.Printf(`Starting to parse "%s"...`, file)
		c := parseConf(file)

		// Start init tasks.
		c.init()

		// Start watching the requested directories.
		w := watcher.NewType()
		watchers = append(watchers, w.ListenFile("./"+ConfigFile, reloadConfig))
		for pattern := range c.watch {
			watchers = append(watchers, w.Listen(pattern, c.watch[pattern]))
		}
	}
}
开发者ID:gocore,项目名称:goal,代码行数:47,代码来源:main.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang config.Set函数代码示例发布时间:2022-05-28
下一篇:
Golang config.NewWarning函数代码示例发布时间: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