Skip to main content
AI
  • Get started with AI

    • Red Hat AI

      Accelerate the development and deployment of enterprise AI solutions.

    • AI learning hub

      Explore learning materials and tools, organized by task.

    • AI interactive demos

      Click through scenarios with Red Hat AI, including training LLMs and more.

    • AI/ML learning paths

      Expand your Red Hat OpenShift AI knowledge using these learning resources.

    • AI quickstarts

      Focused AI use cases designed for fast deployment on Red Hat AI platforms.

    • No-cost AI training

      Foundational Red Hat AI training.

  • Featured resources

    • Red Hat OpenShift AI
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

Red Hat AI Factory with NVIDIA

Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.

Learn
  • Self-guided

    • Documentation

      Find answers, get step-by-step guidance, and learn how to use Red Hat products.

    • Learning paths

      Explore curated walkthroughs for common development tasks.

    • Guided learning

      Receive custom learning paths powered by our AI assistant.

    • See all learning
  • Hands-on

    • Developer Sandbox

      Spin up Red Hat's products and technologies without setup or configuration.

    • Interactive labs

      Learn by doing in these hands-on, browser-based experiences.

    • Interactive demos

      Click through product features in these guided tours.

  • Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics
  • Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
Build
  • Get started

    • Red Hat build of Podman Desktop

      A downloadable, local development hub to experiment with our products and builds.

    • Developer Sandbox

      Spin up Red Hat's products and technologies without setup or configuration.

  • Download products

    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products
  • Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset
  • References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
Community
  • Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions
  • Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github
  • Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

Join the Red Hat Developer program

Download Red Hat products and project builds, access support documentation, learning content, and more.

ConsoleDocsSupport Search
New For you

Recommended

We'll recommend resources you may like as you browse. Try these suggestions for now.

  • Product downloads
  • Cheat sheets
  • Red Hat Developer learning portal
  • Developer blog
  • E-books
  • Developer Sandbox
Log in

Get more with a Red Hat Developer account

  • Product downloads
  • Console access
  • Event registration
  • Training & trials
Explore more account benefitsLog in or register

A subscription may be required for some services.

Contact us

Getting started with go-toolset

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

    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

    • A day in the life of an NVIDIA H100 on Red Hat OpenShift 5

    • Migrate BuildConfigs to builds for Red Hat OpenShift with one plug-in install

    • Run Red Hat Enterprise Linux CoreOS on NVIDIA BlueField DPUs

    • Agent harness engineering: Separating model capabilities from enforcement

    • What's new for developers in Red Hat Enterprise Linux 10.3 and 9.9

    Red Hat Developers logo

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    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
    © 2026 Red Hat

    Red Hat legal and privacy links

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