tool/info-plist: decrease indentation and simplify (#3479)

This commit is contained in:
Oleksandr Redko 2024-09-22 21:38:15 +03:00 committed by GitHub
parent 71da59fd1c
commit 9cd1ce968d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5,24 +5,21 @@ package main
import ( import (
"fmt" "fmt"
"io/ioutil"
"os" "os"
"runtime" "runtime"
) )
func check(e error) {
if e != nil {
panic(e)
}
}
func main() { func main() {
if runtime.GOOS != "darwin" { if runtime.GOOS != "darwin" {
return return
} }
if len(os.Args) == 3 { if len(os.Args) != 3 {
if os.Args[1] == "darwin" && runtime.GOOS == "darwin" { panic("missing arguments")
rawInfoPlistString := `<?xml version="1.0" encoding="UTF-8"?> }
if os.Args[1] != "darwin" {
return
}
rawInfoPlist := `<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
@ -39,13 +36,10 @@ func main() {
</dict> </dict>
</plist> </plist>
` `
infoPlistData := []byte(rawInfoPlistString)
err := ioutil.WriteFile("/tmp/micro-info.plist", infoPlistData, 0644) err := os.WriteFile("/tmp/micro-info.plist", []byte(rawInfoPlist), 0644)
check(err) if err != nil {
panic(err)
}
fmt.Println("-linkmode external -extldflags -Wl,-sectcreate,__TEXT,__info_plist,/tmp/micro-info.plist") fmt.Println("-linkmode external -extldflags -Wl,-sectcreate,__TEXT,__info_plist,/tmp/micro-info.plist")
}
} else {
panic("missing arguments")
}
} }