From 9cd1ce968db0fdf89253c50d78b72a991f2776cc Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Sun, 22 Sep 2024 21:38:15 +0300 Subject: [PATCH] tool/info-plist: decrease indentation and simplify (#3479) --- tools/info-plist.go | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/tools/info-plist.go b/tools/info-plist.go index 89b47846..1707d6de 100644 --- a/tools/info-plist.go +++ b/tools/info-plist.go @@ -5,24 +5,21 @@ package main import ( "fmt" - "io/ioutil" "os" "runtime" ) -func check(e error) { - if e != nil { - panic(e) - } -} - func main() { if runtime.GOOS != "darwin" { return } - if len(os.Args) == 3 { - if os.Args[1] == "darwin" && runtime.GOOS == "darwin" { - rawInfoPlistString := ` + if len(os.Args) != 3 { + panic("missing arguments") + } + if os.Args[1] != "darwin" { + return + } + rawInfoPlist := ` @@ -39,13 +36,10 @@ func main() { ` - infoPlistData := []byte(rawInfoPlistString) - err := ioutil.WriteFile("/tmp/micro-info.plist", infoPlistData, 0644) - check(err) - fmt.Println("-linkmode external -extldflags -Wl,-sectcreate,__TEXT,__info_plist,/tmp/micro-info.plist") - } - } else { - panic("missing arguments") + err := os.WriteFile("/tmp/micro-info.plist", []byte(rawInfoPlist), 0644) + if err != nil { + panic(err) } + fmt.Println("-linkmode external -extldflags -Wl,-sectcreate,__TEXT,__info_plist,/tmp/micro-info.plist") }