vscode development environment to build golang

My computer system is windows10, windows with a user-friendly interface, but is not suitable for building development environments, so the method described in this article are: the use of windows in vscode build go-language development environment on a remote server centos system.

1. Download and install vscode editor (when installed, all the checkboxes on the hook)

Download: https: //code.visualstudio.com/

Remote Development plug-in installed on 2.vscode

The first step: press the shortcut keys Ctrl + Shift + X, into the plugin management page, search for and install the plug-in Remote Development

Step 2: Install openssh client windows, there is provided a method of mounting using powershell

First, Administrator, open powershell

Then, enter the command-line query to obtain the installation package Get-WindowsCapability -Online |? Name -like 'OpenSSH *'

If the status NotPresent, you can use the install command, command Add-WindowsCapability -Online -Name OpenSSH.Client ~~~~ 0.0.1.0

Tip: With Windows 10 2018 Nian 4 month of release, OpenSSH client has been officially launched and installed by default in Windows 10.

The third step: Prepare a centos ubuntu virtual machine or virtual machine, make sure ssh server service on the virtual machine is turned on, and allow remote connections. For example, I was ready centos7 virtual machine, IP address is 192.168.247.133

Step Four: Press the shortcut key ctrl + shift + p search Remote-SSH: Settings, open the page, click Edit in settings.json, in which add "remote.SSH.showLoginTerminal": true,

Step Five: Click the green icon in the lower left corner, select Remote-SSH: Connect to Host and then click Configure SSH Hosts and then select the first point config, default should be a blank file, add the following configuration:

Host Centos7.5
    HostName 192.168.247.133
    Port 22
    User root

Note: where Host behind the name, you can easily name, IP address back HostName is ready virtual machine IP address, Port heel is listening ssh server service port number, the default is 22, User heel is the user name of the remote connection I have here the superuser access.

Step Six: Click vscode the left column of the remote connection icon that button, enter the password next to the good name of the remote virtual machine configuration Click to login to the server

Step Seven: press the shortcut keys Ctrl + Shift + X, into the plugin management page, go search and install (this step operation, can go to a remote server plug-in installed)

3. Install the go language compiler on a remote virtual machine

The first step: to find a browser opens https://studygolang.com/dl latest installation package, copy the download link

Step 2: Use the virtual machine wget to download the installation package

wget https://studygolang.com/dl/golang/go1.13.4.linux-amd64.tar.gz

The third step: mounting the package to extract the appropriate directory

tar -xzf go1.13.4.linux-amd64.tar.gz -C /usr/local/

Step 4: Add the environment variable

echo 'export PATH=$PATH:/usr/local/go/bin' >> /etc/profile

source /etc/profile

Step Five: Configure GOPATH environment variables

mkdir / Golang /

echo 'export GOPATH=/Golang' >> /etc/profile

source /etc/profile

echo $ GOPATH

Step Six: Go to create a project directory

mkdir $GOPATH/LUAGO

4. Open the Go project directory on the remote server in the vscode

 

5. Run the project code

First: Click Terminal, click New Terminal

Then: switch to the code to be run directory

 

 Last: Use go run run code

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/DesignerA/p/11966229.html