Golang Macos Build For Linux

What is Go?Go or Golang is a programming language created by Google in 2009 by Robert Griesemer, Rob Pike, and Ken Thompson.

This project is still under heavy development. The gradle-golang plugin is is designed to give you the power of a professional build tool (in this case Gradle) to build, test (and other great stuff) with your go code. And this without pain of think about the correct installation go sdk, set the. Mar 02, 2018  Remember to include GOOS=linux on Mac when building functions for AWS SAM Local! GOOS=linux go build main.go The local environment is still using Docker (specifically the docker-lambda containers provided by lambci) so the binaries are run in a Linux container, and must be compiled appropriately. Share: Twitter Facebook LinkedIn. Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.

Go language is designed for building simple, fast and reliable software.

In this tutorial i’ll show how to install Go on MacOS, Ubuntu, CentOS and how to create a simple “Hello world!” program on Golang.

Install Go on MacOS, Ubuntu, CentOS

Download an archive with the latest version of Golang for your platform from the official download page (the current version of Go is 1.11.3).

Golang compile for linux

Extract the tar archive files into /usr/local (default Go installation directory):

Configure GoLang Environment

For a system-wide installation of Go it needs to add the following line at the bottom of /etc/profile file:

To specify a workspace (location where you store your Go code) it needs to set Go environment variable GOPATH.

By default, GOPATH is $HOME/go, but you can change it to any location you want (except Go installation directory).

I also recommend to set GOBIN environment variable that specifies location where to install compiled Go programs and add it to PATH.

Set GOPATH, GOBIN and PATH environment variables by adding the following lines at the bottom of your $HOME/.profile file:

Golang Build Tool

Refresh profile:

Verify Golang installation by checking the Go version and environment:

GoLang: Hello World! – Example

Create $GOPATH/src directory:

Create $GOPATH/src/hello.go file with the following contents:

Run go install to compile and install our “Hello World!” program on Go:

Execute hello to run the program:

Build

Go Build Linux On Mac

If the program returns “Hello World!”, then Go is successfully installed and functional.