Skip to content

Instantly share code, notes, and snippets.

@JoeGlines
Created October 14, 2025 11:43
Show Gist options
  • Save JoeGlines/4cecad8db62d9e6d2ad73fd5b2843af6 to your computer and use it in GitHub Desktop.
Save JoeGlines/4cecad8db62d9e6d2ad73fd5b2843af6 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"os"
)
func readConfigFile(fileName string) (string, error) {
data, err := os.ReadFile(fileName)
if err != nil {
return "", fmt.Errorf("failed to read config: %w", err)
}
return string(data), nil
}
func main() {
content, err := readConfigFile("config.txt")
if err != nil {
fmt.Println("Error:", err)
return
}
fmt.Println("Config:", content)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment