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:

  1. 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:
    FSUM6202 Unknown terminal “xterm-256color”.,
    Then execute the following command on z/OS:
    export TERM=dtterm
    If using OMVS, then code oedit instead of vi, 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”)
    }
  2. Save the file when you're done.
  3. Build the program with go build hello.go.
  4. Run the program with ./hello.
  5. 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.