//use a Config value, not Config pointer.
//this prevents future modification from outside the library.
331404
func New(c Config) (*Foo, error) {
	//ensure proper initialization of Foo
	foo := &Foo{
		c:    c,
		bar:  42 + c.Zip,
		bazz: 21 + c.Zop,
	}

	return foo, nil
}
952606
func (c *Config) AddConfig(section string, option string, value string) bool {
	if section == "" {
		section = DEFAULT_SECTION
	}

	if _, ok := c.data[section]; !ok {
		c.data[section] = make(map[string]string)
	}

	_, ok := c.data[section][option]
	c.data[section][option] = value

	return !ok
}
28190
func SetConfig(filepath string) *Config {
	c := new(Config)
	c.filepath = filepath

	return c
}
386137
func (env *CustomEnv) Const(ident string) reflect.Value {
	if v := env.Env.Const(ident); v.IsValid() && v.Type().Kind() == reflect.String {
		s := v.String()
		return(reflect.ValueOf(strings.ToLower(s)))
	} else {
		return v
	}
}
393141
func (c *ConfigFile) SetValue(section, key, value string) bool {
	// Blank section name represents DEFAULT section.
	if len(section) == 0 {
		section = DEFAULT_SECTION
	}
	if len(key) == 0 {
		return false
	}

	if c.BlockMode {
		c.lock.Lock()
		defer c.lock.Unlock()
	}

	// Check if section exists.
	if _, ok := c.data[section]; !ok {
		// Execute add operation.
		c.data[section] = make(map[string]string)
		// Append section to list.
		c.sectionList = append(c.sectionList, section)
	}

	// Check if key exists.
	_, ok := c.data[section][key]
	c.data[section][key] = value
	if !ok {
		// If not exists, append to key list.
		c.keyList[section] = append(c.keyList[section], key)
	}
	return !ok
}
687512
func (api *DiskAPI) Config(id int64, disk *sacloud.DiskEditValue) (bool, error) {
	var (
		method = "PUT"
		uri    = fmt.Sprintf("%s/%d/config", api.getResourceURL(), id)
	)

	return api.modify(method, uri, disk)
}
1022563
func (c *Config) UseFeature(name string) bool {
	if len(c.Features) <= 0 {
		return false
	}

	for _, x := range c.Features {
		items := strings.Split(x, "=")
		if items[0] != name {
			continue
		}
		if len(items) == 1 {
			return true
		}

		v, err := strconv.ParseBool(items[1])
		if err != nil {
			return false
		}
		return v
	}

	return false
}
955225
func (c *Configs) setConfig(confName configName, value *ConfigSettings) {
	assert(len(confName) == len(c.ConfigVariables))
	assert(value != nil)
	key := confName.key()
	pair, ok := c.byConfig[key]
	assert(!ok, "setConfig must not override existing keys (%s => %v)", key, pair.value)
	c.byConfig[key] = configPair{confName, value}
}
971468
func configValuesSet(config map[string]interface{}) map[string]interface{} {
	flatten := make(map[string]interface{})
	for k, v := range config {
		if m, isMap := v.(map[string]interface{}); isMap && !flatOptions[k] {
			for km, vm := range m {
				flatten[km] = vm
			}
			continue
		}

		flatten[k] = v
	}
	return flatten
}
962819
func randUseForPlugin(plugin *dt.Plugin) string {
	if plugin.Config.Usage == nil {
		return ""
	}
	return plugin.Config.Usage[rand.Intn(len(plugin.Config.Usage))]
}
749832
func Use(c context.Context, s Client) context.Context {
	return context.WithValue(c, &contextKey, s)
}
102911
func (c *tracker) Use() (*state.Controller, error) {
	c.mu.Lock()
	defer c.mu.Unlock()

	if c.references == 0 {
		return nil, ErrControllerClosed
	}
	c.references++
	return c.st, nil
}
1361500
func (s *Action) Config(ctx context.Context, c *cli.Context) error {
	if len(c.Args()) < 1 {
		s.printConfigValues(ctx, "")
		return nil
	}

	if len(c.Args()) == 1 {
		s.printConfigValues(ctx, "", c.Args()[0])
		return nil
	}

	if len(c.Args()) > 2 {
		return ExitError(ctx, ExitUsage, nil, "Usage: %s config key value", s.Name)
	}

	if err := s.setConfigValue(ctx, c.String("store"), c.Args()[0], c.Args()[1]); err != nil {
		return ExitError(ctx, ExitUnknown, err, "Error setting config value")
	}
	return nil
}
891176
func (f *Fibre) Use(m MiddlewareFunc) MiddlewareFunc {
	f.middleware = append(f.middleware, m)
	return m
}
367697
func (api *LoadBalancerAPI) Config(id int64) (bool, error) {
	var (
		method = "PUT"
		uri    = fmt.Sprintf("%s/%d/config", api.getResourceURL(), id)
	)
	return api.modify(method, uri, nil)
}
513648
func (c *configCommand) setConfig(client applicationAPI, ctx *cmd.Context) error {
	if c.useFile {
		return c.setConfigFromFile(client, ctx)
	}

	settings, err := c.validateValues(ctx)
	if err != nil {
		return errors.Trace(err)
	}

	result, err := client.Get(c.branchName, c.applicationName)
	if err != nil {
		return err
	}

	for k, v := range settings {
		configValue := result.CharmConfig[k]

		configValueMap, ok := configValue.(map[string]interface{})
		if ok {
			// convert the value to string and compare
			if fmt.Sprintf("%v", configValueMap["value"]) == v {
				logger.Warningf("the configuration setting %q already has the value %q", k, v)
			}
		}
	}

	if client.BestAPIVersion() < 6 {
		err = client.Set(c.applicationName, settings)
	} else {
		err = client.SetApplicationConfig(c.branchName, c.applicationName, settings)
	}
	return block.ProcessBlockedError(err, block.BlockChange)
}
1236188
func (confSrc *MemoryConfigurationSource) AddKeyValue(key string, value interface{}) error {
	if !confSrc.ChanStatus {
		<-confSrc.CallbackCheck
		confSrc.ChanStatus = true
	}

	event := new(core.Event)
	event.EventSource = confSrc.GetSourceName()
	event.Key = key
	event.Value = value

	confSrc.Lock()
	defer confSrc.Unlock()
	if _, ok := confSrc.Configurations[key]; !ok {
		event.EventType = core.Create
	} else {
		event.EventType = core.Update
	}

	confSrc.Configurations[key] = value

	if confSrc.callback != nil {
		confSrc.callback.OnEvent(event)
	}

	return nil
}