diff options
| author | joesis | 2017-08-28 15:02:20 +0800 | 
|---|---|---|
| committer | GitHub | 2017-08-28 15:02:20 +0800 | 
| commit | e78cfcfa229acdd9af7489540c20419ee5cb05a8 (patch) | |
| tree | 7bb33595a16c1a57b4454f014b48fc08e1ec2406 /example/main.go | |
| parent | ef254071ef3abfdf0a220f76fcdd468d24bff519 (diff) | |
| parent | 1698df20cadf507689bd091174b466e7c6c6876e (diff) | |
| download | systray-e78cfcfa229acdd9af7489540c20419ee5cb05a8.tar.bz2 | |
Merge pull request #28 from getlantern/flashlight-258-ox
Made onExit run reliably and process terminate on quit
Diffstat (limited to 'example/main.go')
| -rw-r--r-- | example/main.go | 18 | 
1 files changed, 8 insertions, 10 deletions
| diff --git a/example/main.go b/example/main.go index e2193be..4b927da 100644 --- a/example/main.go +++ b/example/main.go @@ -2,7 +2,8 @@ package main  import (  	"fmt" -	"os" +	"io/ioutil" +	"time"  	"github.com/getlantern/systray"  	"github.com/getlantern/systray/example/icon" @@ -10,15 +11,11 @@ import (  )  func main() { -	file, err := os.Create("out.txt") -	if err != nil { -		fmt.Println("Couldn't create out.txt") -		return -	} -	defer file.Close()  	onExit := func() { -		file.Write([]byte("On Exit...")) -		file.Sync() +		fmt.Println("Starting onExit") +		now := time.Now() +		ioutil.WriteFile(fmt.Sprintf(`on_exit_%d.txt`, now.UnixNano()), []byte(now.String()), 0644) +		fmt.Println("Finished onExit")  	}  	// Should be called at the very beginning of main().  	systray.Run(onReady, onExit) @@ -31,8 +28,9 @@ func onReady() {  	mQuit := systray.AddMenuItem("Quit", "Quit the whole app")  	go func() {  		<-mQuit.ClickedCh +		fmt.Println("Requesting quit")  		systray.Quit() -		fmt.Println("Quit now...") +		fmt.Println("Finished quitting")  	}()  	// We can manipulate the systray in other goroutines | 
