Simplest code with Fyne hang forever

[Problem solved itself, but I not know why]
Got interested in Go language and was curious to see how to build simplest desktop application. I not enough familiar with it, so not managed troubleshoot by myself. Using Windows 10, after executing code inside command line, or inside VSCode, it just hangs, without doing anything. Other commands like “go mod init …”, “go mod tidy” works fast enough in same Windows or VSCode terminals .
What can I check and fix, to make code run?

[Fyne recognizes main necessary dependencies] 1 hosted at ImgBB — ImgBB
[The code itself] 2 hosted at ImgBB — ImgBB

[Soluition] While I googling and writing this question for 15 minutes, I saw my app surprisingly finally started. Executing again “Go run” or “Go build” now works much faster, about 1 second, instead of freezing.
Not deleting question, in case some other frustrated newbies will search for solution. In other questions people recommended delete and execute “go mod init …” and “go mod tidy” again, but it not helped in my case to speed it up. I wonder what happened, and what this incredible long delay was. Is it possible that it was related to some C compilation time?

Yes, that’ll be reason. You would have had a similar experience if you’d written a trivial desktop app with gotk4, for the same reason. C compilers tend to be much slower than the Go compiler.

As you’ve noticed subsequent builds are fast, because the built fyne packages are cached. So the Go compiler only has to recompile your own app package(s) if they’ve changed. If you build using the “-a” flag (for example go run -a .) then the cached packages will be ignored, and you’ll be waiting a long time again. Cached package builds are also specific to the Go version, so if you upgrade to a new Go version the first build will be slow again.


Thank you for response. It was quite frustrating to not see any compilation related progress messages, even simple notification that it started - just simple blank line. But I noticed some gcc related processes titles, which had run in Task Manager. It was a hint about compilation run in background, due it consumed some RAM.

The Go compiler will print the commands that it runs if the -x flag is used. For example go build -x .. That can provide some reassurance that the build is progressing and has not simply stalled.