Go set up development environments - Installing and configuring the SDK (window, linux, mac)

Go build a development environment 2.1 Windows - installation and configuration SDK

  2.1.1 introduced the SDK

    1) SDK full name ( S oftware  D evelopment  K IT Software Development Kit)

    2) SDK is available to developers, which contains the corresponding language development kit

  2.1.1 Download SDK toolkit

    1) Go to the language of the official website: golang.org, for various reasons, it may not be accessible.

    2) SDK Download: Golang China https://www.golangtc.com/download

    3)  How to select the corresponding sdk version

    

  2.1.1 windows  installation sdk

    1) Windows  under various versions of the SDK description:

    Windows down: according to your system is 32 -bit or download 64:

    System 32: go1.9.2.windows-386.zip

    System 64: go1.9.2.windows-amd64.zip

 

    1) Please note: the installation path do not have Chinese or special symbols such as spaces

    2) SDK installation directory is recommended: windows I generally installed in d: / programs

    3) When installed, the installation is essentially fool, extract can be used

    4) install the demo:

    5)  After decompression, we'll see d: / go  directory, this is sdk

    

 

    

 

    How to test our go the sdk installed successfully.

    

 

 

 

  2.1.1 windows  configuration Golang environment variables:

    Why do you need to configure the environment variables  

    

    Configuration environment variable introduced

    According to windows system to find executable programs principle, you can be Go where the path environment variable is defined to allow the system to help us look for the implementation of the program run, so can perform in any directory go instruction.

    In Go development, environment variables which need to be configured

     

    

     Step 1: First open interface environment variable configuration

     

 

 

 

     Step 2: Configure our environment variables

     

 

 

     

    A description of the figure:

    1) Path environment variable does not need to create, because the system itself, you can later increase

    2)增加Go manner Bin: ; Pasento GOROOT Pasento \ Bin

    

    For a description of the FIG.

      1) GOPATH  : what you're after path go to store items, namely the working directory

      2) GOPATH:是一个新建的环境变量

 

    测试一下我们的环境变量是否配置 ok  

    

 

    注意:配置环境变量后,需要重新打开一次 dos 的终端,这样环境变量才会生效。

 

2.1 Linux 下搭建 Go 开发环境-安装和配置 SDK

  2.1.1 Linux 下安装 SDK: 

    1) Linux  SDK 的各个版本说明:

  Linux 下:根据系统是 32 位还是 64 位进行下载:

  32 位系统:go1.9.2.linux-386.tar.gz

  64 位系统:go1.9.2.linux-amd64.tar.gz 如何确认你的 linux 是多少位:

  

 

  1) 请注意:安装路径不要有中文或者特殊符号如空格等

  2) SDK 安装目录建议: linux 放在 /opt 目录下

  3) 安装时,解压即可,我们使用的是 tar.gz

    步 1: go1.9.2.linux-amd64.tar.gz ubuntu

      2: go1.9.2.linux-amd64.tar.gz /opt 下    

    

    步骤 3: cd /opt

    步骤 4:tar -zxvf go1.9.2.linux-amd64.tar.gz [解压后,就可以看到一个 go 目录] 步骤 5: cd go/bin

    步骤 6:./go version

    

 

     

  2.1.1 Linux 下配置 Golang 环境变量

    步骤 1:使用 root 的权限来编辑 vim /etc/profile 文件

    

    步骤 2: 如果需要生效的话,需要注销一下(重新登录),再使用

    

 

 

2.1 Mac 下搭建Go 开发环境-安装和配置 SDK

  2.1.1 mac 下安装Go sdk

    1) Mac SDK 的各个版本说明:

    Mac OS  下:只有 64 位的软件安装包

    Mac OS  系统的安装包:go1.9.2.darwin-amd64.tar.gz

    1) 请注意:安装路径不要有中文或者特殊符号如空格等

    2) SDK 安装目录建议: Mac 一般放在用户目录下 go_dev/go 下

    3) 安装时,解压即可

    步骤 1 先将我们的安装文件 go1.9.2.darwin-amd64.tar.gz 上传到 mac

    步骤 2: 先在用户目录下,创建一个目录 go_dev ,  将我们上传的文件 移动到 go_dev 目录步骤 3  解压  tar -zxvf go1.9.2.darwin-amd64.tar.gz

    步骤 4: 解压后,我们会得到一个目录 go 进入到 go/bin 就是可以使用

     

    这里还是有一个问题,就是如果我们不做 bin 目录下,就使用不了 go 程序。因此我们仍然需要配置 go的环境变量

      

    Mac 下配置Golang 环境变量:

 

      步骤 1:使用 root 用户,修改 /etc/profile 增加环境变量的配置

      

 

      步骤 2: 配置完后,需要重新注销用户,配置才会生效.

      

Guess you like

Origin www.cnblogs.com/Essaycode/p/12181643.html