INNER CODE UNIT · Go

main

stacklok/toolhive · cmd/help/dedupe-enums/main.go:34

func main() {
	for _, path := range os.Args[1:] {
		data, err := os.ReadFile(path) // #nosec G304 -- path is a CLI argument we control (Taskfile/verify.sh)
		if err != nil {
			fmt.Fprintln(os.Stderr, err)
			os.Exit(1)
		}

		fixed := jsonArray.ReplaceAllStringFunc(string(data), dedupeJSONBlock)
		fixed = yamlArray.ReplaceAllStringFunc(fixed, dedupeYAMLBlock)

		if fixed == string(data) {
			continue
		}
		if err := os.WriteFile(path, []byte(fixed), 0o600); err != nil {
			fmt.Fprintln(os.Stderr, err)
			os.Exit(1)
		}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…