Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Getting started with go-toolset

October 31, 2017
Jakub Čajka
Related topics:
Developer ToolsGo
Related products:
Red Hat Enterprise Linux

Share:

    One of the new software collections we’ve introduced this fall is for Go, the programming language that aims to make it easy to build simple, reliable, and efficient software. Go is a compiled, statically typed language in the C/C++ tradition with garbage collection, concurrent programming support, and memory safety features.

    In go-toolset-7, we’re including everything you need to start programming in Go on Red Hat Enterprise Linux 7, in the familiar format of software collections. In this release, we’re shipping golang as a Tech Preview. (NOTE: The “-7” in our toolset name is to sync with the other collections now being released, devtoolset-7, rust-toolset-7, and llvm-toolset-7.)

    Enabling the go-toolset repositories

    Before we start let’s settle on the baseline. You will need a RHEL 7 system if you don't have one you can sign up for free at Red Hat Developer Program and get free RHEL 7 for development purposes here. And then install it on a bare metal machine or in VM on VM host of your choosing.

    With the RHEL 7 installation ready, we will need to obtain and enable go-toolset subscription/repository:

    subscription-manager repos --enable rhel-7-server-devtools-rpms

    Now you should see rhel-7-server-devtools-rpms as an enabled repo in yum repo list. Something similar to:

    [root@localhost ~]# yum repolist enabled
    Loaded plugins: product-id, search-disabled-repos, subscription-manager
    repo id status
    
    rhel-7-server-devtools-rpms/x86_64 137
    
    rhel-7-server-rpms/7Server/x86_64 17,249
    
    rhel-7-server-rt-beta-rpms/x86_64 15
    
    rhel-7-server-rt-rpms/7Server/x86_64 233
    
    repolist: 17,634

    Let’s install the go-toolset

    yum install go-toolset-7

    This is not enough if you want to run the integrated Go compiler test-suites. You will need two additional packages go-toolset-7-golang-tests and.go-toolset-7-golang-misc. These are not installed by default to save on the installed footprint, as they are not needed in regular Go use.

    To use the go-toolset, you have to enable it using the scl tool as it is backed by the software collections technology, like the developer toolset for gcc&co.

    scl enable go-toolset-7 go version

    Let’s get some Go project and "install" it.

    scl enable go-toolset-7 "GOPATH=`realpath ~/go` go get -d github.com/cpuguy83/go-md2man"

    We have just downloaded the sources (using -d) for go package with all its dependencies, into the src dir under your GOPATH. As we used option -d, we need now to install/build the binaries using;

    scl enable go-toolset-7 "GOPATH=`realpath ~/go` go install github.com/cpuguy83/go-md2man"

    now you can run the binary which got installed under ~/go/bin/.

    ~/go/bin/go-md2man --help
    Usage of /home/user/go/bin/go-md2man:
     -in string
            Path to file to be processed (default: stdin)
    -out string
            Path to output processed file (default: stdout)

    If you plan on using upstream go projects installed in your GOPATH, it is a good idea to add $GOPATH/bin on to your system PATH variable.

    Note: Red Hat does not support any packages/projects obtained using the "go get" command in any way.

    See also:

    1. https://golang.org/cmd/go/#hdr-Download_and_install_packages_and_dependencies
    2. https://golang.org/cmd/go/#hdr-Compile_and_install_packages_and_dependencies
    3. https://golang.org/cmd/go/#hdr-Test_packages

    Kick starting your ("Hello World") project

    Let’s create a directory for your project to live in:

    mkdir $YOUR_MAIN_GOPATH/src/hello/
    Note: If you are not sure about your GOPATH execute "scl enable go-toolset-7 go env" and look for GOPATH in output, your "main" GOPATH is the first path before: i.e. if you see,GOPATH=/home/usr/go:/root/go your GOPATH is /home/usr/goor you can use the standard location as ~/go.

    Afterwards, create the hello.go file using your favorite text editor, in the just created directory with the following content:

    package main
    import (
      "fmt"
      "net/http"
    )
    
    func Welcome(w http.ResponseWriter, req *http.Request) {
    
      fmt.Fprintf(w, "Welcome to the Go toolset.")
    
    }
    
    func main() {
    
    
      fmt.Println("Hello.")
      fmt.Println("Starting http server.")
    
    // Register handler function
    
    http.HandleFunc("/welcome", Welcome)
    
      fmt.Println("Go to localhost:8080/welcome To terminate press CTRL+C")
    
    // Start server
    
      http.ListenAndServe(":8080", nil)
    }

    Now you can build and run the hello, project:

    scl enable go-toolset-7 go build hello/hello

    This will place the built binary into your current working directory. Of course, you can also only “install” it using install command and run it from bin directory in your GOPATH.

    See also:

    1. https://golang.org/cmd/go/#hdr-GOPATH_environment_variable

    Whether you are new to Linux or have experience, downloading this cheat sheet can assist you when encountering tasks you haven’t done lately.

    Last updated: August 3, 2022

    Recent Posts

    • Create and enrich ServiceNow ITSM tickets with Ansible Automation Platform

    • Expand Model-as-a-Service for secure enterprise AI

    • OpenShift LACP bonding performance expectations

    • Build container images in CI/CD with Tekton and Buildpacks

    • How to deploy OpenShift AI & Service Mesh 3 on one cluster

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2025 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue