GO Basic questions

Hi,

I need to write a small application which will be deployed on Linux. I have following questions regarding the same:

  1. Do I need to write the code on linux machine only, so that the compiled file is not an EXE [on windows]?
  2. Once I have a compiled file, do I need to install ANYTHING on my production linux server to run that GO program, like JRE for JAva etc?
  3. If I build/use Oracle driver in my dev environment, so that my program can connect to Oracle database, would I have to port something on my production server as well, so that my compiled program can use that drive on other server as well? [its kind of same as number 2 but more specific to drivers].

Thanks

1 Like

@newgouser, cross compile is don’t as described in this link :-https://stackoverflow.com/questions/20829155/how-to-cross-compile-from-windows-to-linux

Basically in short it says set GOOS and GOARCH variable in environment and then use go commands in it shell build or install

Hi @newgouser

  1. You can write and compile the code on any platform supported by Go (Linux BSD Mac Windows)

Eg. to compile for Linux Mac OS X and Windows
GOOS=linux GOARCH=amd64 go build -o myprogram.linux
GOOS=darwin GOARCH=amd64 go build -o myprogram.darwin
GOOS=windows GOARCH=amd64 go build -o myprogram.exe

  1. You won’t need to install anything else on the production server. The compiled binary will just work. You will need to copy up any files the binary depends on, like HTML templates etc.

  2. The oracle driver will be included in the binary. You’ll need to read in the specific configuration details (address, username, password) from an environment variable or config file.

3 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.