Troubleshooting Guide: Package io/fs Is Not in GOROOT - Fix & Solutions

This documentation aims to provide an easy-to-follow guide to help you resolve the "Package io/fs is not in GOROOT" issue in your Go programming environment. This error occurs when you try to import the io/fs package while using an older version of Go. The io/fs package was introduced in Go 1.16, so using a previous version of Go will result in this error.

Follow the step-by-step instructions below to fix this issue and explore our FAQ section for further clarifications.

Table of Contents

  1. Requirements
  2. Step-by-Step Solution
  3. FAQs


Before proceeding with the solution, ensure that you have the following:

  • A Go programming environment installed on your computer
  • Access to a command line or terminal

Step-by-Step Solution

Step 1: Check your current Go version

Open your terminal or command prompt and enter the following command:

go version

This will display the current version of Go installed on your system. If your Go version is older than 1.16, proceed to the next step.

Step 2: Update Go to the latest version

To update Go to the latest version, follow these instructions based on your operating system:


  1. Visit the official Go downloads page and download the latest version for Windows.
  2. Run the downloaded MSI file and follow the installation prompts.


  1. If you installed Go using Homebrew, run the following command:
brew upgrade go
  1. If you installed Go manually, visit the official Go downloads page and download the latest version for macOS. Then, follow the installation instructions on the official Go installation page.


  1. Visit the official Go downloads page and download the latest version for Linux.
  2. Follow the installation instructions on the official Go installation page.

Step 3: Verify the updated Go version

After updating Go, run the following command to verify the new version:

go version

Ensure that the displayed version is 1.16 or newer. If the update was successful, you should no longer encounter the "Package io/fs is not in GOROOT" error.


1. What is GOROOT?

GOROOT is an environment variable that specifies the location of your Go installation. It is used by the Go tools to find the Go standard library and other necessary files.

2. What is the io/fs package?

The io/fs package is a standard library package introduced in Go 1.16. It provides a file system interface, which allows you to work with different file systems in a uniform and abstracted manner.

3. Can I use the io/fs package with Go versions older than 1.16?

No, the io/fs package is only available in Go 1.16 and later versions. To use this package, you must update your Go installation to version 1.16 or newer.

4. How do I check if the io/fs package is available in my Go installation?

You can check the availability of the io/fs package by running the following command:

go doc io/fs

If the package is available, this command will display the package documentation. If not, you will see an error message.

5. How do I set the GOROOT environment variable?

If you need to set the GOROOT environment variable, follow the instructions for your operating system below:


  1. Right-click on "Computer" or "This PC" and select "Properties."
  2. Click on "Advanced system settings."
  3. In the "System Properties" window, click on the "Environment Variables" button.
  4. Click on "New" under "System variables" and enter GOROOT as the variable name and the path to your Go installation as the variable value.

macOS and Linux:

  1. Open your terminal and run the following command:
nano ~/.bash_profile
  1. Add the following line to the file, replacing /path/to/go with the path to your Go installation:
export GOROOT=/path/to/go

Save the file and exit the editor.

Run the following command to apply the changes:

source ~/.bash_profile

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.