"Tutorial" WIN10_WSL installation Golang1.10-2018-06-22

Source: Internet
Author: User
Tags golang tutorial

WIN10_WSL installation Golang

1 ~ WSL Installation

1. Open Win10 Bash on the Ubuntu on Windows feature

    1. Open Windows设置 (shortcut key win+i) search应用和功能
    2. Select the relevant settings in the upper left程序和功能
    3. In the new window, select启用或关闭Windows功能
    4. In the conversation window, pull the scroll bar to the bottom, select 适用于Linux的 Windows 子系统 Click OK and wait for the system reboot to complete.

2. Choose your preferred Linux distribution

Open win10应用商店 Searchwsl

Choose获取这些应用

1.png

Pick a favorite Linux distribution

2.png

I chose OpenSUSE Leap 42.

Wait for the installation to complete when an icon is created in the Start menu

3.png

Several ways to open WSL

  • Click the program icon in the Start menu


  • Run (shortcut key win + R) input bash orwsl
  • Right-click on the Start menu (or win+x) to select PowerShell (cmd) PS: I replaced the cmd with PowerShell, usually this is cmd

    Input bash orwsl

2 ~ Golang Installation

1. Download Golang

1. Download the tar file from code.google.com and extract it to the /usr/local directory and /usr/local/go Create the Go directory tree in. I downloaded it toD:/apps/

$ cd /mnt/d/apps$ // cd /mnt/[盘符/路径]$ sudo tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz$ // sudo tar -C /usr/local -xzf go1.10.3.linux-amd64.tar.gz$ // 我安装的是10.3版本
  • The tar command needs to run in root mode
  • If you are unable to access Google, you can try to download from Golang China/Go language network and other learning exchange websites

2, setting environment variables

To /usr/local/go/bin add to the PATH environment variable, you need to add this line to your $HOME/.profile file:

$ sudo nano ~/.profile$ // sudo vi ~/.profileexport GOROOT=$HOME/goexport PATH=$PATH:$GOROOT/bin

3, set the working environment variable

    1. Create go_work a folder and add it to the$HOME/.profile
$ mkdir /mnt/c/go_work$ sudo nano ~/.profile$ // sudo vi ~/.profileexport GOPATH=/mnt/c/go_workexport PATH=$PATH:$GOPATH/bin

To see go_work If the catalog was created successfully

Restart Terminal

4, test installation and work environment variable settings are correct
New in the work environmenthello.go

$ nano /mnt/c/go_work/src/github.com/soulmo/hello/hello.go$ // vi /mnt/c/go_work/src/github.com/soulmo/hello/hello.gopackage mainimport "fmt"func main() {    fmt.Printf("hello, world\n")}

Then run it with the Go tool:

$ go -Versiongo version go1.10.3 linux/amd64$ go install hello.go$ hellohello, world

If you see the "Hello, World" message, then your go is properly installed, the system variable is set up correctly and asked a good question.

! Note that the go get agent issue must be switched to the terminal environment to set up the Git agent

Q: Why write a tutorial
A: I did not find the WIN10-WSL installation Setup Golang tutorial, although it is no different from the Linux installation, but still want to write
Where is the root directory of the Q:WSL?
A: %USER%AppData\Local\Packages\[发行版]\ It is not recommended to change its files outside of the terminal environment, the permissions problem is a bit troublesome
Q:WSL Terminal recommendation
A:cmder toss a bit good use, but I use is wsl.exe and Vscode bring terminal (lazy toss, install a oh my zsh very good)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.