Getting started with IBM Open Enterprise SDK for Go
To get started with IBM® Open Enterprise SDK for Go, you can work with the Go edition of a "Hello World" program as an example.
Prerequisites
Before getting started, you must meet the following prerequisites:
- Ensure that the required environment variables are set up properly. See Environment variables for SMP/E installation or Environment variables for PAX archive installation.
- Ensure that the Go version is up to date. Check your Go version with the following
line:
go version
When you're requested by service, use this command to display the current Go version built date and commit from official builds:/bin/strings $(type -p go) | /bin/awk '/License/{ for(i=0;i<6;i++) {print;getline}}'
Note:go version <executable-name>
does not work where <executable-name> is any executable built with the Go compiler on z/OS®.
Procedure
You can set up a simple file with the Hello World
message through the following
steps:
- Create a file named "hello.go" with the following
command:
/bin/vi -W filecodeset=ISO8859-1 hello.go
Note: If you get the following error message:
Then execute the following command on z/OS:FSUM6202 Unknown terminal “xterm-256color”.,
If using OMVS, then codeexport TERM=dtterm
oedit
instead ofvi
, for example:touch hello.go chtag -tc 819 hello.go oedit hello.go
which contains the following program within the file:package main import “fmt” func main() { fmt.Println(“Hello World”) }
- Save the file when you're done.
- Build the program with
go build hello.go
. - Run the program with
./hello
. - The message is printed as follows:
Hello World
Through the previous steps, you have completed the getting started task of compiling a sample Go program.