当前位置: 首页>>代码示例>>Golang>>正文


Golang config.ReadConfigFile函数代码示例

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


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


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