News for hackers. Stuff that matters.
Re:Show HN: Go Plan9 Memo, Speeding Up Calculations 450% by ncruces on Saturday October 19, 2024 @01:28AM (#41885834)
It gets even more amazing than that. Look at this bit from my GitHub Actions: https://github.com/ncruces/go-sqlite3/blob/fefee692dbfad39f6...

I install QEMU (I have the same setup locally), then it's one line each to run unit tests for: Linux 386, arm64, riscv64, ppc64le and s390x.

With QEMU installed, all you have to do is:

    GOARCH=bla go test ./...
Re:Show HN: Go Plan9 Memo, Speeding Up Calculations 450% by cryptofistMonk on Saturday October 19, 2024 @11:43AM (#41888442)
Wait is go test automatically running it under QEMU or what's going on here?
Re:Show HN: Go Plan9 Memo, Speeding Up Calculations 450% by cryptofistMonk on Saturday October 19, 2024 @11:51AM (#41888505)
Ah I found this https://ctrl-c.us/posts/test-goarch I guess it's qemu-user-binfmt registering the alternate bin formats to automatically run under QEMU, that's pretty neat
Re:Show HN: Go Plan9 Memo, Speeding Up Calculations 450% by ncruces on Saturday October 19, 2024 @12:25PM (#41888755)
Yep.

The Go build system runs under your current architecture, cross-compiling tests to your target architecture.

Then, the Go test runner also runs under your current architecture, orchestrating running your cross compiled test binaries.

Since you registered to run cross-compiled binaries under QEMU, those test binaries magically run through QEMU.

The Go test runner collects test results, and reports back to you.

The first run might be slowish, as the Go compiler needs to cross compile the standard library and all your dependencies to your target platform. But once that's done and cached, and if your tests are fast, the edit-test cycle becomes pretty quick.