Home  >  Article  >  Backend Development  >  golang 1.10 installation

golang 1.10 installation

WBOY
WBOYOriginal
2023-05-18 21:11:07527browse

With the development of golang, more and more developers are beginning to use this language for development. Golang 1.10 is an important version of the language. It adds many important new features, such as support for function literals, enhanced testing support, etc.

In this article, we will introduce the detailed steps on how to install golang 1.10 and above.

  1. Prerequisites

Before installing golang, you need to meet the following requirements:

  1. gcc and make are installed.
  2. The old version of golang has been uninstalled.

If gcc and make are not installed on your operating system, you can install them through the package manager.

Fedora/CentOS/RHEL:

sudo yum install gcc
sudo yum install make

Debian/Ubuntu:

sudo apt-get install gcc
sudo apt-get install make
  1. Download golang

You can download golang from the official website https ://golang.org/dl/ Download the golang binaries for your operating system.

Here, we will choose to download the binary file of golang 1.10.3 version. Please select and download the latest version here based on your operating system and architecture.

  1. Install golang
  2. Create the golang directory:
sudo mkdir /usr/local/go
  1. Extract the downloaded golang binary file into the golang directory:
sudo tar -C /usr/local -xzf go1.10.3.linux-amd64.tar.gz
  1. Configure golang environment variables:

Add the following content to the ~/.bash_profile file:

export PATH=$PATH:/usr/local/go/bin
export GOPATH=$HOME/go

here We set GOPATH to $HOME/go, you can set it to other directories as needed.

  1. Update bash environment variables:
source ~/.bash_profile

By running the go version command, you can see that golang has been installed and successfully configured.

  1. Test

Create a simple helloworld.go file:

package main

import "fmt"

func main() {
    fmt.Println("Hello, World!")
}

Run the following command:

go run helloworld.go

The output should be:

Hello, World!

At this point, you have successfully installed and configured golang 1.10, and you can now start using it for golang development.

Conclusion

The above are the installation steps of golang 1.10. If you are not familiar with golang yet, you can consult relevant literature and learning materials to learn more about golang so that you can better use the language for development.

The above is the detailed content of golang 1.10 installation. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn