// formatSourceCode formats source files
12306
func FormatSourceCode(filename string) {
	cmd := exec.Command("gofmt", "-w", filename)
	if err := cmd.Run(); err != nil {
		beeLogger.Log.Warnf("Error while running gofmt: %s", err)
	}
}
1036832
func ioOutputFormatSourceFile(ld *LineData, b *bytes.Buffer) error {
	_, err := b.WriteString(ld.SourceFile)
	return err
}
608246
func (s *CreateEventSubscriptionInput) SetSourceType(v string) *CreateEventSubscriptionInput {
	s.SourceType = &v
	return s
}
627573
func NewSourceSpec(ps *helpers.PathSpec, fs afero.Fs) *SourceSpec {
	cfg := ps.Cfg
	defaultLang := cfg.GetString("defaultContentLanguage")
	languages := cfg.GetStringMap("languages")

	disabledLangsSet := make(map[string]bool)

	for _, disabledLang := range cfg.GetStringSlice("disableLanguages") {
		disabledLangsSet[disabledLang] = true
	}

	if len(languages) == 0 {
		l := langs.NewDefaultLanguage(cfg)
		languages[l.Lang] = l
		defaultLang = l.Lang
	}

	ignoreFiles := cast.ToStringSlice(cfg.Get("ignoreFiles"))
	var regexps []*regexp.Regexp
	if len(ignoreFiles) > 0 {
		for _, ignorePattern := range ignoreFiles {
			re, err := regexp.Compile(ignorePattern)
			if err != nil {
				helpers.DistinctErrorLog.Printf("Invalid regexp %q in ignoreFiles: %s", ignorePattern, err)
			} else {
				regexps = append(regexps, re)
			}

		}
	}

	return &SourceSpec{ignoreFilesRe: regexps, PathSpec: ps, SourceFs: fs, Languages: languages, DefaultContentLanguage: defaultLang, DisabledLanguages: disabledLangsSet}

}
763069
func zipSource() string {
	cwd := filepath.Join(workDir, "src")
	check(os.MkdirAll(cwd, 0755))
	image := goDockerImage
	args := []string{
		"run",
		"--rm",
		"--volume=" + cwd + ":/OUT",
		"--volume=" + path.Join(releaseDir, "zip-source.go") + ":" + zipSourceProgram + ":ro",
	}
	if isWIP() {
		args = append(args, "--volume="+localCamliSource()+":/IN:ro",
			image, goCmd, "run", zipSourceProgram, "--rev=WIP:/IN")
	} else {
		args = append(args, image, goCmd, "run", zipSourceProgram, "--rev="+rev())
	}
	cmd := exec.Command("docker", args...)
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	if err := cmd.Run(); err != nil {
		log.Fatalf("Error zipping Perkeep source in go container: %v", err)
	}
	archiveName := "perkeep-src.zip"
	// can't use os.Rename because invalid cross-device link error likely
	cmd = exec.Command("mv", filepath.Join(cwd, archiveName), releaseDir)
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	if err := cmd.Run(); err != nil {
		log.Fatalf("Error moving source zip from %v to %v: %v", filepath.Join(cwd, archiveName), releaseDir, err)
	}
	fmt.Printf("Perkeep source successfully zipped in %v\n", releaseDir)
	return archiveName
}
412859
func (s *CreateApplicationVersionRequest) SetSourceCodeUrl(v string) *CreateApplicationVersionRequest {
	s.SourceCodeUrl = &v
	return s
}
1333526
func (fp *formatParser) staticCode(i int, r rune) error {
	data := []byte(fp.format[fp.start:i])
	fp.addStatic(data)
	fp.start = i
	fp.code = (*formatParser).codeCode
	fp.next = (*formatParser).codeNext
	fp.end = (*formatParser).codeEnd
	return nil
}
315000
func (cfg *ubuntuCloudConfig) AddPackageSource(src packaging.PackageSource) {
	cfg.attrs["apt_sources"] = append(cfg.PackageSources(), src)
}
242597
func (s *CreateApplicationVersionOutput) SetSourceCodeUrl(v string) *CreateApplicationVersionOutput {
	s.SourceCodeUrl = &v
	return s
}
901560
func (g *storageProvider) VolumeSource(cfg *storage.Config) (storage.VolumeSource, error) {
	return &volumeSource{
		client: g.client,
	}, nil
}
1194914
func (s *TextInput) SetSourceLanguageCode(v string) *TextInput {
	s.SourceLanguageCode = &v
	return s
}
1278548
func (self *Otto) CompileWithSourceMap(filename string, src, sm interface{}) (*Script, error) {
	program, err := self.runtime.parse(filename, src, sm)
	if err != nil {
		return nil, err
	}

	cmpl_program := cmpl_parse(program)

	script := &Script{
		version:  scriptVersion,
		program:  cmpl_program,
		filename: filename,
		src:      program.File.Source(),
	}

	return script, nil
}
141143
func Source(filename string, src []byte) ([]byte, error) {
	module, err := ast.ParseModule(filename, string(src))
	if err != nil {
		return nil, err
	}
	formatted, err := Ast(module)
	if err != nil {
		return nil, fmt.Errorf("%s: %v", filename, err)
	}
	return formatted, nil
}
1253609
func (r *Client) GetDatasourceTypes() (map[string]DatasourceType, error) {
	var (
		raw     []byte
		dsTypes = make(map[string]DatasourceType)
		code    int
		err     error
	)
	if raw, code, err = r.get("api/datasources/plugins", nil); err != nil {
		return nil, err
	}
	if code != 200 {
		return nil, fmt.Errorf("HTTP error %d: returns %s", code, raw)
	}
	err = json.Unmarshal(raw, &dsTypes)
	return dsTypes, err
}
247355
func (s *EventSubscription) SetSourceType(v string) *EventSubscription {
	s.SourceType = &v
	return s
}
895209
func FormatCharmResource(res charmresource.Resource) FormattedCharmResource {
	return FormattedCharmResource{
		Name:        res.Name,
		Type:        res.Type.String(),
		Path:        res.Path,
		Description: res.Description,
		Revision:    res.Revision,
		Origin:      res.Origin.String(),
		Fingerprint: res.Fingerprint.String(), // ...the hex string.
		Size:        res.Size,
	}
}
1155463
func (s *EventCategoriesMap) SetSourceType(v string) *EventCategoriesMap {
	s.SourceType = &v
	return s
}