Hello everyone. I want to encapsulate the golang program into an app under mac (create the app directory structure manually), but it cannot run normally after clicking the app. The record in the mac system log is:
I tested it by writing a file, and the code is as follows:
func check(e error) { if e != nil { panic(e) } }
func main() {
index := 0
f, err := os.Create("testdat.txt")
check(err)
defer f.Close()
for {
index += 1
n3, err := f.WriteString("test app: ")
check(err)
t := strconv.Itoa(index)
n3, err = f.WriteString(t)
check(err)
n3, err = f.WriteString("times \n")
check(err)
fmt.Printf("wrote %d bytes\n", n3)
time.Sleep(1 * time.Second)
}
f.Sync()
}
Excuse me, what is the cause of the problem after packaging the app? How to fix it? thanks.