commit 3c95065

Artur Manuel  ·  2026-04-27 18:19:04 +0000 UTC
parent 90f0ec4
chore(fmt): gofmt
8 files changed,  +17, -17
+1, -1
1@@ -29,7 +29,7 @@ var server = cli.Command{
2 		},
3 	},
4 	Action: func(ctx context.Context, cmd *cli.Command) error {
5-		log := slog.Default()  
6+		log := slog.Default()
7 		mux := http.NewServeMux()
8 		templateFile := cmd.StringArg("template")
9 		mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
+2, -2
 1@@ -3,7 +3,7 @@ package internal
 2 import "fmt"
 3 
 4 type DesktopInfo struct {
 5-	SessionType string
 6+	SessionType    string
 7 	CurrentDesktop string
 8 }
 9 
10@@ -24,5 +24,5 @@ func (d DesktopInfo) String() string {
11 	default:
12 		currentDesktop = d.CurrentDesktop
13 	}
14-	return fmt.Sprintf("%s (%s)", currentDesktop, sessionType) 
15+	return fmt.Sprintf("%s (%s)", currentDesktop, sessionType)
16 }
+2, -2
 1@@ -21,12 +21,12 @@ func (info MemoryInfo) UnmarshalText(data []byte) error {
 2 		var key string
 3 		var value int
 4 		if k, v, ok := strings.Cut(scanner.Text(), ":"); !ok {
 5-			return fmt.Errorf("failed to parse line %d of meminfo: expected ':'", line) 
 6+			return fmt.Errorf("failed to parse line %d of meminfo: expected ':'", line)
 7 		} else {
 8 			key = k
 9 			v = strings.TrimSuffix(strings.TrimSpace(v), " kB")
10 			if size, err := strconv.Atoi(v); err != nil {
11-				return fmt.Errorf("failed to parse line %d of meminfo: %v", line, err)  
12+				return fmt.Errorf("failed to parse line %d of meminfo: %v", line, err)
13 			} else {
14 				value = size
15 			}
+1, -1
1@@ -64,6 +64,6 @@ DirectMap1G:    12582912 kB`)
2 func TestUnmarshalMeminfo(t *testing.T) {
3 	meminfo := make(MemoryInfo)
4 	if err := meminfo.UnmarshalText(MEMINFO); err != nil {
5-		t.Fatal(err) 
6+		t.Fatal(err)
7 	}
8 }
+2, -2
 1@@ -19,10 +19,10 @@ func (os OsRelease) UnmarshalText(text []byte) error {
 2 	for scanner.Scan() {
 3 		key, value, ok := strings.Cut(scanner.Text(), "=")
 4 		if !ok {
 5-			return fmt.Errorf("failed to parse line %d of os-release: expected '='", line) 
 6+			return fmt.Errorf("failed to parse line %d of os-release: expected '='", line)
 7 		}
 8 		if value[0] == '"' {
 9-			value = value[1:len(value)-1]
10+			value = value[1 : len(value)-1]
11 		}
12 		os[key] = value
13 		line++
+3, -3
 1@@ -30,12 +30,12 @@ VERSION_ID="26.05"`)
 2 func TestUnmarshalOSRelease(t *testing.T) {
 3 	var os = make(OsRelease)
 4 	if err := os.UnmarshalText(OS_RELEASE); err != nil {
 5-		t.Fatal(err) 
 6+		t.Fatal(err)
 7 	}
 8 	if os["NAME"] != "NixOS" {
 9-		t.Errorf("expected NAME to be NixOS, was %s instead", os["NAME"]) 
10+		t.Errorf("expected NAME to be NixOS, was %s instead", os["NAME"])
11 	}
12 	if os["BUG_REPORT_URL"] != "https://github.com/NixOS/nixpkgs/issues" {
13-		t.Errorf("expected BUG_REPORT_URL to be https://github.com/NixOS/nixpkgs/issues, was %s instead", os["BUG_REPORT_URL"]) 
14+		t.Errorf("expected BUG_REPORT_URL to be https://github.com/NixOS/nixpkgs/issues, was %s instead", os["BUG_REPORT_URL"])
15 	}
16 }
+1, -1
1@@ -16,7 +16,7 @@ type SystemInfo struct {
2 	Terminal      string
3 	MemInfo       MemoryInfo
4 	DesktopInfo   DesktopInfo
5-	Locale string
6+	Locale        string
7 }
8 
9 func GetSysinfo() (SystemInfo, error) {
+5, -5
 1@@ -10,10 +10,10 @@ import (
 2 )
 3 
 4 var templateFuncMap = template.FuncMap{
 5-	"add": func(a int, b int) int { return a + b },
 6+	"add":      func(a int, b int) int { return a + b },
 7 	"subtract": func(a int, b int) int { return a - b },
 8 	"multiply": func(a int, b int) int { return a * b },
 9-	"divide": func(a int, b int) int { return a / b },
10+	"divide":   func(a int, b int) int { return a / b },
11 }
12 
13 func GetPasswd() (Passwd, error) {
14@@ -119,7 +119,7 @@ func GetDesktopInfo() DesktopInfo {
15 	if !ok {
16 		currentDesktop = "Unknown"
17 	}
18-	sessionType, ok := os.LookupEnv("XDG_SESSION_TYPE") 
19+	sessionType, ok := os.LookupEnv("XDG_SESSION_TYPE")
20 	if !ok {
21 		sessionType = "Unknown"
22 	}
23@@ -137,10 +137,10 @@ func GetLocale() string {
24 }
25 
26 func BuildTemplate(w io.Writer, file string, s SystemInfo) error {
27-	name := filepath.Base(file) 
28+	name := filepath.Base(file)
29 	master, err := template.New(name).Funcs(templateFuncMap).ParseFiles(file)
30 	if err != nil {
31-		return fmt.Errorf("failed to parse %s: %v", file, err) 
32+		return fmt.Errorf("failed to parse %s: %v", file, err)
33 	}
34 	if err := master.ExecuteTemplate(w, name, s); err != nil {
35 		return fmt.Errorf("failed to write template to writer: %v", err)