golang compiling for hosting

The task is to compile a program for the site on Golang, which will be called inside the CGI script. Hosting is not virtual, there is no way to compile on it. When compiling with the command


GOOS=linux GOARCH=amd64 go build -o hello_linux_x64


A file is created that only works on this PC. I tried to compile on the test server, the files differ in size. On the hosting, too, these files do not run and issues an error:

Illegal instruction (core dumped)

What is surprising, I tried to compile for Windows both 32 and 64 bit, both programs worked.

How do I compile for hosting. If you offer an option with a virtual machine, then tell me on what specific hardware and architecture emulation can be performed as on a hoster, because I have already tried to raise a virtual machine with Ubuntu 16.04.2 LTS, compile and transfer to hosting - it does not work.

Wednesday developments: Architecture: x86_64 Model name: Intel(R) Pentium(R) CPU G620 @ 2.60GHz OS: Ubuntu 18.04.5 LTS x64 Go 1.15.7

Hosting: Architecture: x86_64 Model name: Intel(R) Xeon(R) CPU E5-2630 v2 @ 2.60GHz OS: Ubuntu 16.04.2 LTS

Test Server: Architecture: x86_64 Model name: Intel(R) Xeon(R) CPU E5420 @ 2.50GHz OS: Ubuntu 18.04.5 LTS 64x Go 1.15.7

Code the test is the simplest:


import "fmt"

func main() {
    fmt.Printf("Content-type: text/html \n\n")
    fmt.Printf("<html><body>hello, world</body></html>\n")
}
Author: depers, 2021-01-24