當前位置: 首頁>>代碼示例>>Golang>>正文


Golang gcfg.ReadFileInto函數代碼示例

本文整理匯總了Golang中code/google/com/p/gcfg.ReadFileInto函數的典型用法代碼示例。如果您正苦於以下問題:Golang ReadFileInto函數的具體用法?Golang ReadFileInto怎麽用?Golang ReadFileInto使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了ReadFileInto函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: LoadConfigs

func LoadConfigs() {
	defer setDefaults(&cfg) // Load the defaults at the end of the function call
	cfg = Config{}
	gcfg.ReadFileInto(&cfg, globalFile)
	gcfg.ReadFileInto(&cfg, configFile)
	gcfg.ReadFileInto(&cfg, overrideFile)
}
開發者ID:peernohell,項目名稱:shoehorn,代碼行數:7,代碼來源:config.go

示例2: ParseConfig

func ParseConfig(inputFile string) (subnets []*scanner.Subnet, params Params, e error) {
	type Config struct {
		Parameters Params
		Subnet     map[string]*struct {
			Network string
		}
	}
	config := Config{}
	e = gcfg.ReadFileInto(&config, inputFile)
	if e != nil {
		return nil, Params{}, e
	}

	params = config.Parameters
	for subnetName, network := range config.Subnet {
		log.Printf("Adding subnet %s %s", subnetName, network.Network)
		_, ipNet, e := net.ParseCIDR(network.Network)
		if e != nil {
			return nil, Params{}, e
		}
		sub := scanner.NewSubnet(subnetName, ipNet.String())
		generateAllInSubnet(ipNet, sub)
		subnets = append(subnets, sub)
	}
	return
}
開發者ID:nealjc,項目名稱:ipreg,代碼行數:26,代碼來源:config.go

示例3: ReadConfiguration

// ReadConfiguration loads a client configuration from a local configuration file
// and verifies that GnuPG's secring is available
func ReadConfiguration(file string) (conf Configuration, err error) {
	defer func() {
		if e := recover(); e != nil {
			err = fmt.Errorf("ReadConfiguration() -> %v", e)
		}
	}()
	_, err = os.Stat(file)
	if err != nil {
		fmt.Fprintf(os.Stderr, "no configuration file found at %s\n", file)
		err = MakeConfiguration(file)
		if err != nil {
			panic(err)
		}
	}
	err = gcfg.ReadFileInto(&conf, file)
	if conf.GPG.Home == "" {
		gnupgdir := os.Getenv("GNUPGHOME")
		if gnupgdir == "" {
			gnupgdir = "/.gnupg"
		}
		conf.GPG.Home = FindHomedir() + gnupgdir
	}
	_, err = os.Stat(conf.GPG.Home + "/secring.gpg")
	if err != nil {
		panic("secring.gpg not found")
	}
	// if trailing slash is missing from API url, add it
	if conf.API.URL[len(conf.API.URL)-1] != '/' {
		conf.API.URL += "/"
	}
	return
}
開發者ID:izogain,項目名稱:mig,代碼行數:34,代碼來源:client.go

示例4: BootstrapConfig

func BootstrapConfig() (*Config, error) {
	home := os.Getenv("STF_HOME")
	if home == "" {
		var err error
		home, err = os.Getwd()
		if err != nil {
			log.Fatalf("Failed to get home from env and Getwd: %s", err)
		}
	}

	cfg := Config{}
	file := os.Getenv("STF_CONFIG")
	if file == "" {
		file = path.Join("etc", "config.gcfg")
	}
	if !filepath.IsAbs(file) {
		file = path.Join(home, file)
	}

	err := gcfg.ReadFileInto(&cfg, file)
	if err != nil {
		return nil, errors.New(
			fmt.Sprintf(
				"Failed to load config file '%s': %s",
				file,
				err,
			),
		)
	}

	cfg.FileName = file
	cfg.Prepare()
	return &cfg, nil
}
開發者ID:stf-storage,項目名稱:go-stf-server,代碼行數:34,代碼來源:config.go

示例5: init

func init() {
	err := gcfg.ReadFileInto(&MasterConfig, "kirisurf.conf")
	log.Debug("Read configuration successfully")
	if err != nil {
		panic(err.Error())
	}
}
開發者ID:kaustavha,項目名稱:kirisurf,代碼行數:7,代碼來源:config.go

示例6: main

func main() {
	configFilePath := flag.String("config", "./etc/goahead.ini", "Configuration file path")
	help := flag.Bool("help", false, "Show me the help!")
	run := flag.Bool("run", false, "Run server")
	build := flag.Bool("build", false, "Create the scaffold")

	flag.Parse()

	if *help || (!(*run) && !(*build)) {
		showHelp()
		return
	}

	err := gcfg.ReadFileInto(&_cfg, *configFilePath)
	if err != nil {
		log.Fatal(err)
	}
	db := database.Create(&(_cfg.Database))
	err = db.IsValid()
	if err != nil {
		log.Fatal(err)
	}

	if *build {
		buildScaffold(db)
		return
	}

	if *run {
		runServer(db)
		return
	}

}
開發者ID:Zocprint,項目名稱:go301,代碼行數:34,代碼來源:main.go

示例7: parseConfigFile

func parseConfigFile(filename string, cfg *Config) error {
	// Just testing config structs
	err := gcfg.ReadFileInto(cfg, configFile)
	if err != nil {
		panic(err)
	}
}
開發者ID:jsimnz,項目名稱:omega,代碼行數:7,代碼來源:config.go

示例8: ReadConfig

func ReadConfig(cfg *Config, path string) (ok bool) {
	err := gcfg.ReadFileInto(cfg, path)
	if err != nil {
		return false
	}
	return true
}
開發者ID:pra85,項目名稱:resizer,代碼行數:7,代碼來源:config.go

示例9: getCfg

// Read configuration.
func getCfg() *cfgType {
	var c cfgType
	var errorSeen bool

	// set up some sane default configuration settings:
	c.Main.Zpoolstatusrefresh = 10
	c.Main.Zpoolstatuscmd = "zpool status"
	c.Main.Zfslistrefresh = 60
	c.Main.Zfslistcmd = "zfs list -H -o name,avail,used,usedsnap,usedds,usedrefreserv,usedchild,refer,mountpoint -d 0"
	c.Main.Zfslistusagecmd = "zfs list -H -o name,avail,used,usedsnap,usedds,usedrefreserv,usedchild,refer,mountpoint -r -t all"
	c.Leds.Ledctlcmd = "ledctl"
	c.Severity.Pooladded = notifier.INFO
	c.Severity.Poolremoved = notifier.INFO
	c.Severity.Poolstatuschanged = notifier.INFO
	c.Severity.Poolstatuscleared = notifier.INFO
	c.Severity.Poolerrorschanged = notifier.INFO
	c.Severity.Devadded = notifier.INFO
	c.Severity.Devremoved = notifier.INFO
	c.Severity.Devreaderrorsincreased = notifier.INFO
	c.Severity.Devwriteerrorsincreased = notifier.INFO
	c.Severity.Devcksumerrorsincreased = notifier.INFO
	c.Severity.Devadditionalinfochanged = notifier.INFO
	c.Severity.Devadditionalinfocleared = notifier.INFO

	// read configuration settings:
	err := gcfg.ReadFileInto(&c, cfgFile)
	checkCfgErr(cfgFile, "", "", "", err, &errorSeen)

	if errorSeen {
		return nil
	}
	return &c
}
開發者ID:0987363,項目名稱:zfswatcher,代碼行數:34,代碼來源:setup.go

示例10: LoadConfig

func LoadConfig(filename string) (Config, error) {
	var c Config

	err := gcfg.ReadFileInto(&c, filename)

	return c, err
}
開發者ID:njohns-pica9,項目名稱:ss1,代碼行數:7,代碼來源:config.go

示例11: init

func init() {
	flag.Parse()
	err := gcfg.ReadFileInto(&cfg, *configFile)
	if err != nil {
		log.Fatal(err)
	}

	session, err = r.Connect(r.ConnectOpts{
		Address:  cfg.Database.Host + ":" + cfg.Database.Port, //localhost:28015
		Database: cfg.Database.DB,                             //DB: cats
	})
	if err != nil {
		log.Fatal("Could not connect")
	}
	res, err := r.DBCreate(cfg.Database.DB).RunWrite(session)
	if err != nil {
		log.Println(err.Error())
	}

	fmt.Printf("%d DB created\n", res.DBsCreated)
	r.DB(cfg.Database.DB).TableCreate("instacat").Run(session)
	log.Println("Create table instacat.")
	r.Table("instacat").IndexCreate("time").Run(session)
	log.Println("Create index time.")
	r.Table("instacat").IndexCreate("place", r.IndexCreateOpts{Geo: true}).Run(session)
	log.Println("Create index place.")
}
開發者ID:jimmyplaza,項目名稱:RethinkDB-Instagram,代碼行數:27,代碼來源:main.go

示例12: main

func main() {
	var (
		err  error
		conf Config
	)
	flag.Usage = func() {
		fmt.Fprintf(os.Stderr, "%s - a worker verifying agents that fail to authenticate\n", os.Args[0])
		flag.PrintDefaults()
	}
	var configPath = flag.String("c", "/etc/mig/agent_verif_worker.cfg", "Load configuration from file")
	flag.Parse()
	err = gcfg.ReadFileInto(&conf, *configPath)
	if err != nil {
		panic(err)
	}
	// set a binding to route events from event.Q_Agt_Auth_Fail into the queue named after the worker
	// and return a channel that consumes the queue
	workerQueue := "migevent.worker." + workerName
	consumerChan, err := workers.InitMqWithConsumer(conf.Mq, workerQueue, event.Q_Agt_Auth_Fail)
	if err != nil {
		panic(err)
	}
	fmt.Println("started worker", workerName, "consuming queue", workerQueue, "from key", event.Q_Agt_Auth_Fail)
	for event := range consumerChan {
		fmt.Printf("%s\n", event.Body)
	}
	return
}
開發者ID:Novemburr,項目名稱:mig,代碼行數:28,代碼來源:main.go

示例13: readConfig

func readConfig() {

	err := gcfg.ReadFileInto(&IcerayCfg, *ConfigPath)
	if err != nil {
		log.Fatal("Error opening config file: " + err.Error())
	}

	if *Hostname == DEFAULT_HOSTNAME && IcerayCfg.Server.Hostname != "" {
		*Hostname = IcerayCfg.Server.Hostname
	}

	if *Port == DEFAULT_PORT && IcerayCfg.Server.Port != 0 {
		*Port = IcerayCfg.Server.Port
	}

	mountpoint := IcerayCfg.Server.Mount
	if mountpoint[0] != '/' {
		mountpoint = "/" + mountpoint
	}

	if *Mount == DEFAULT_MOUNTPOINT && IcerayCfg.Server.Mount != "" {
		*Mount = IcerayCfg.Server.Mount
	}

	if *Username == DEFAULT_USERNAME && IcerayCfg.Server.User != "" {
		*Username = IcerayCfg.Server.User
	}

	if *Password == DEFAULT_PASSWORD && IcerayCfg.Server.Password != "" {
		*Password = IcerayCfg.Server.Password
	}
}
開發者ID:jdarnold,項目名稱:iceray,代碼行數:32,代碼來源:config.go

示例14: LoadConfig

// LoadConfig loads the configuration from given file path
func LoadConfig(filename string) {
	err := gcfg.ReadFileInto(&Config, filename)
	if err != nil {
		logger.Logger.Print("Config: ", err)
		log.Fatal("Config: ", err)
	}
}
開發者ID:beres,項目名稱:gofaxip,代碼行數:8,代碼來源:config.go

示例15: main

func main() {
	var (
		confPath string
	)

	flag.StringVar(&confPath, "f", "./ipcapcom.conf", "path to config file")
	flag.Parse()
	err := gcfg.ReadFileInto(&cfg, confPath)
	if err != nil {
		fmt.Fprintf(os.Stderr, "error reading config file: %v\n", err)
		os.Exit(1)
	}

	r := mux.NewRouter()
	r.HandleFunc("/ping", handlePing).Methods("GET")
	r.HandleFunc("/apply", handleApply).Methods("POST")
	r.HandleFunc("/purge", handlePurge).Methods("GET")
	r.PathPrefix("/").Handler(http.FileServer(http.Dir(cfg.General.StaticDir)))
	http.Handle("/", context.ClearHandler(r))
	go reaper()
	err = http.ListenAndServe(":"+cfg.General.ListenPort, nil)
	if err != nil {
		fmt.Fprintf(os.Stderr, "error: %v\n", err)
		os.Exit(1)
	}
}
開發者ID:ameihm0912,項目名稱:ipcapcom,代碼行數:26,代碼來源:ipcapcom.go


注:本文中的code/google/com/p/gcfg.ReadFileInto函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。