Skip to content

[feature] Common lib #3

@iglov

Description

@iglov

Write common lib for:

// Helper function to capitalize the first letter of a string.
func capitalizeManufacturer(manufacturer string) string {
	if len(manufacturer) == 0 {
		return manufacturer
	}
	return strings.ToUpper(manufacturer[:1]) + strings.ToLower(manufacturer[1:])
}
// Read one-liner text files, strip newline.
func slurpFile(path string) string {
	data, err := os.ReadFile(path)
	if err != nil {
		return ""
	}
	return strings.TrimSpace(string(data))
}

// If a deferred function has any return values, they are discarded when the function completes.
func Check(f func() error) {
	if err := f(); err != nil {
		fmt.Println("Received error:", err)
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions