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


Golang ucfg.PathSep函數代碼示例

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


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

示例1: newTestLumberjackOutput

func newTestLumberjackOutput(
	t *testing.T,
	test string,
	config map[string]interface{},
) outputs.BulkOutputer {
	if config == nil {
		config = map[string]interface{}{
			"hosts": []string{getLogstashHost()},
			"index": testLogstashIndex(test),
		}
	}

	plugin := outputs.FindOutputPlugin("logstash")
	if plugin == nil {
		t.Fatalf("No logstash output plugin found")
	}

	cfg, _ := ucfg.NewFrom(config, ucfg.PathSep("."))
	output, err := plugin(cfg, 0)
	if err != nil {
		t.Fatalf("init logstash output plugin failed: %v", err)
	}

	return output.(outputs.BulkOutputer)
}
開發者ID:jarpy,項目名稱:beats,代碼行數:25,代碼來源:logstash_test.go

示例2: makeTestClients

func makeTestClients(c map[string]interface{},
	newClient func(string) (ProtocolClient, error),
) ([]ProtocolClient, error) {
	cfg, err := ucfg.NewFrom(c, ucfg.PathSep("."))
	if err != nil {
		return nil, err
	}

	return MakeClients(cfg, newClient)
}
開發者ID:jarpy,項目名稱:beats,代碼行數:10,代碼來源:mode_test.go

示例3: Read

// Read reads the configuration from a yaml file into the given interface structure.
// In case path is not set this method reads from the default configuration file for the beat.
func Read(out interface{}, path string) error {

	if path == "" {
		path = *configfile
	}

	filecontent, err := ioutil.ReadFile(path)
	if err != nil {
		return fmt.Errorf("Failed to read %s: %v. Exiting.", path, err)
	}
	filecontent = expandEnv(filecontent)

	config, err := yaml.NewConfig(filecontent, ucfg.PathSep("."))
	if err != nil {
		return fmt.Errorf("YAML config parsing failed on %s: %v. Exiting.", path, err)
	}

	err = config.Unpack(out, ucfg.PathSep("."))
	if err != nil {
		return fmt.Errorf("Failed to apply config %s: %v. Exiting. ", path, err)
	}
	return nil
}
開發者ID:jarpy,項目名稱:beats,代碼行數:25,代碼來源:cfgfile.go

示例4: TestNestedPath

func TestNestedPath(t *testing.T) {
	input := []byte(`
    c.b: true
  `)

	c, err := NewConfig(input, ucfg.PathSep("."))
	if err != nil {
		t.Fatalf("failed to parse input: %v", err)
	}

	var verify struct {
		C struct{ B bool }
	}
	err = c.Unpack(&verify)
	assert.NoError(t, err)
	assert.True(t, verify.C.B)
}
開發者ID:radoondas,項目名稱:apachebeat,代碼行數:17,代碼來源:yaml_test.go

示例5: newTestKafkaOutput

func newTestKafkaOutput(t *testing.T, topic string, useType bool) outputs.Outputer {

	config := map[string]interface{}{
		"hosts":          []string{getTestKafkaHost()},
		"broker_timeout": "1s",
		"timeout":        1,
		"topic":          topic,
		"use_type":       useType,
	}

	cfg, err := ucfg.NewFrom(config, ucfg.PathSep("."))
	assert.NoError(t, err)
	output, err := New(cfg, 0)
	assert.NoError(t, err)

	return output
}
開發者ID:jarpy,項目名稱:beats,代碼行數:17,代碼來源:kafka_integration_test.go

示例6: SetChild

func (c *Config) SetChild(name string, idx int, value *Config) error {
	return c.access().SetChild(name, idx, value.access(), ucfg.PathSep("."))
}
開發者ID:McStork,項目名稱:beats,代碼行數:3,代碼來源:config.go

示例7: Bool

func (c *Config) Bool(name string, idx int) (bool, error) {
	return c.access().Bool(name, idx, ucfg.PathSep("."))
}
開發者ID:McStork,項目名稱:beats,代碼行數:3,代碼來源:config.go

示例8: SetFloat

func (c *Config) SetFloat(name string, idx int, value float64) error {
	return c.access().SetFloat(name, idx, value, ucfg.PathSep("."))
}
開發者ID:McStork,項目名稱:beats,代碼行數:3,代碼來源:config.go

示例9: SetString

func (c *Config) SetString(name string, idx int, value string) error {
	return c.access().SetString(name, idx, value, ucfg.PathSep("."))
}
開發者ID:McStork,項目名稱:beats,代碼行數:3,代碼來源:config.go

示例10: Float

func (c *Config) Float(name string, idx int) (float64, error) {
	return c.access().Float(name, idx, ucfg.PathSep("."))
}
開發者ID:McStork,項目名稱:beats,代碼行數:3,代碼來源:config.go

示例11: Child

func (c *Config) Child(name string, idx int) (*Config, error) {
	sub, err := c.access().Child(name, idx, ucfg.PathSep("."))
	return fromConfig(sub), err
}
開發者ID:McStork,項目名稱:beats,代碼行數:4,代碼來源:config.go

示例12: String

func (c *Config) String(name string, idx int) (string, error) {
	return c.access().String(name, idx, ucfg.PathSep("."))
}
開發者ID:McStork,項目名稱:beats,代碼行數:3,代碼來源:config.go

示例13: Int

func (c *Config) Int(name string, idx int) (int64, error) {
	return c.access().Int(name, idx, ucfg.PathSep("."))
}
開發者ID:McStork,項目名稱:beats,代碼行數:3,代碼來源:config.go

示例14: NewConfigFrom

func NewConfigFrom(from interface{}) (*Config, error) {
	c, err := ucfg.NewFrom(from, ucfg.PathSep("."))
	return fromConfig(c), err
}
開發者ID:McStork,項目名稱:beats,代碼行數:4,代碼來源:config.go

示例15: Unpack

func (c *Config) Unpack(to interface{}) error {
	return c.access().Unpack(to, ucfg.PathSep("."))
}
開發者ID:McStork,項目名稱:beats,代碼行數:3,代碼來源:config.go


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