// include loads the file specified by the given include in the given Module.
//
// The path to the file is relative to the ThriftPath of the given module.
484273
func (c compiler) include(m *Module, include *ast.Include) (*IncludedModule, error) {
	if len(include.Name) > 0 {
		// TODO(abg): Add support for include-as flag somewhere.
		return nil, includeError{
			Include: include,
			Reason:  includeAsDisabledError{},
		}
	}

	ipath := filepath.Join(filepath.Dir(m.ThriftPath), include.Path)
	incM, err := c.load(ipath)
	if err != nil {
		return nil, includeError{Include: include, Reason: err}
	}

	return &IncludedModule{Name: fileBaseName(include.Path), Module: incM}, nil
}
1048964
func (fsc *FetchSourceContext) Include(includes ...string) *FetchSourceContext {
	fsc.includes = append(fsc.includes, includes...)
	return fsc
}
1255030
func Generate(m *compile.Module, o *Options) error {
	if !filepath.IsAbs(o.ThriftRoot) {
		return fmt.Errorf(
			"ThriftRoot must be an absolute path: %q is not absolute",
			o.ThriftRoot)
	}

	if !filepath.IsAbs(o.OutputDir) {
		return fmt.Errorf(
			"OutputDir must be an absolute path: %q is not absolute",
			o.OutputDir)
	}

	importer := thriftPackageImporter{
		ImportPrefix: o.PackagePrefix,
		ThriftRoot:   o.ThriftRoot,
	}

	// Mapping of filenames relative to OutputDir to their contents.
	files := make(map[string][]byte)
	genBuilder := newGenerateServiceBuilder(importer)

	generate := func(m *compile.Module) error {
		moduleFiles, err := generateModule(m, importer, genBuilder, o)
		if err != nil {
			return generateError{Name: m.ThriftPath, Reason: err}
		}
		if err := mergeFiles(files, moduleFiles); err != nil {
			return generateError{Name: m.ThriftPath, Reason: err}
		}
		return nil
	}

	// Note that we call generate directly on only those modules that we need
	// to generate code for. If the user used --no-recurse, we're not going to
	// generate code for included modules.
	if o.NoRecurse {
		if err := generate(m); err != nil {
			return err
		}
	} else {
		if err := m.Walk(generate); err != nil {
			return err
		}
	}

	plug := o.Plugin
	if plug == nil {
		plug = plugin.EmptyHandle
	}

	if sgen := plug.ServiceGenerator(); sgen != nil {
		res, err := sgen.Generate(genBuilder.Build())
		if err != nil {
			return err
		}

		if err := mergeFiles(files, res.Files); err != nil {
			return err
		}
	}

	for relPath, contents := range files {
		fullPath := filepath.Join(o.OutputDir, relPath)
		directory := filepath.Dir(fullPath)

		if err := os.MkdirAll(directory, 0755); err != nil {
			return fmt.Errorf("could not create directory %q: %v", directory, err)
		}

		if err := ioutil.WriteFile(fullPath, contents, 0644); err != nil {
			return fmt.Errorf("failed to write %q: %v", fullPath, err)
		}
	}

	return nil
}
1120726
func includes(a []string, s string) bool {
	for _, as := range a {
		if as == s {
			return true
		}
	}
	return false
}
176198
func (api *VPCRouterAPI) Include(key string) *VPCRouterAPI {
	api.include(key)
	return api
}
153086
func Load() {
	pwd, _ := os.Getwd()
	goenv := os.Getenv("GOENV")
	envFile := ".env"

	if len(goenv) > 0 && goenv != "development" {
		envFile = fmt.Sprintf("%s.%s", envFile, goenv)
	}

	localFile := envFile + ".local"
	env.ReadEnv(path.Join(pwd, envFile))
	env.ReadEnv(path.Join(pwd, localFile))
}
1177671
func (v *Module) String() string {
	if v == nil {
		return "<nil>"
	}

	var fields [3]string
	i := 0
	fields[i] = fmt.Sprintf("ImportPath: %v", v.ImportPath)
	i++
	fields[i] = fmt.Sprintf("Directory: %v", v.Directory)
	i++
	fields[i] = fmt.Sprintf("ThriftFilePath: %v", v.ThriftFilePath)
	i++

	return fmt.Sprintf("Module{%v}", strings.Join(fields[:i], ", "))
}
1026038
func (api *ProductLicenseAPI) Include(key string) *ProductLicenseAPI {
	api.include(key)
	return api
}
1012893
func (d *Dependencies) includes(needle string) bool {
	for _, name := range d.All {
		if name == needle {
			return true
		}
	}
	return false
}
152330
func (api *ArchiveAPI) Include(key string) *ArchiveAPI {
	api.include(key)
	return api
}
110094
func (api *InterfaceAPI) Include(key string) *InterfaceAPI {
	api.include(key)
	return api
}
890288
func (f *File) Load() (*Config, error) {
	var err error
	if !utils.Exists(f.FilePath) {
		return nil, errors.New("Error: I Can't find the config file at [" + f.FilePath + "]")
	}

	// read file
	f.Data, err = ioutil.ReadFile(f.FilePath)
	if err != nil {
		return nil, err
	}

	// parse file
	return f.Parse()
}
261515
func Load(path string, v interface{}) error {
	lock.Lock()
	defer lock.Unlock()
	f, err := os.Open(path)
	if err != nil {
		return err
	}
	defer f.Close()
	return Unmarshal(f, v)
}
789066
func (api *SSHKeyAPI) Include(key string) *SSHKeyAPI {
	api.include(key)
	return api
}
1114262
func (api *DatabaseAPI) Include(key string) *DatabaseAPI {
	api.include(key)
	return api
}
391746
func (section *Section) AddInclude(filename string) {
	section.includes = append(section.includes, filename)
}
1263043
func (api *CDROMAPI) Include(key string) *CDROMAPI {
	api.include(key)
	return api
}