1 install go

apt install golang

将会同时安装下列软件:
  golang-1.9 golang-1.9-doc golang-1.9-go golang-1.9-src golang-doc golang-go
  golang-src
建议安装:
  bzr
下列【新】软件包将被安装:
  golang golang-1.9 golang-1.9-doc golang-1.9-go golang-1.9-src golang-doc
  golang-go golang-src
2 set env

vim $HOME/.profile and add

export GOROOT=/usr/share/go-1.9
export GOPATH=$HOME/go

使环境变量生效

source $HOME/.profile

全局的 可以编辑添加到 /etc/profile

source ~/.bash_profile

You can do this by adding this line to your /etc/profile (for a system-wide installation) or $HOME/.profile:

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

3 install vscode

https://code.visualstudio.com/docs/?dv=linux64_deb

https://vscode.cdn.azure.cn/stable/0759f77bb8d86658bc935a10a64f6182c5a1eeba/code_1.19.1-1513676564_amd64.deb

dpkg -i code_1.19.1-1513676564_amd64.deb

install go Go for Visual Studio Code

4 debug with vscode

if error :Failed to continue: "Cannot find Delve debugger. Install from https://github.com/derekparker/delve & ensure it is in your "GOPATH/bin" or "PATH"."

should

go get github.com/derekparker/delve/cmd/dlv

开始调试 from:https://zhuanlan.zhihu.com/p/26473355

选中要调试的main.go, 点击F5, 既可以开始调试

调试快捷键和Visual Studio系一致

  • F9 切换断点
  • F10 Step over
  • F11 Step in
  • Shift+F11 Step out

注意点

  • 某些结构体成员无法直接显示时, 可以直接选中变量名, 添加到监视, 或者右键点击: "调试:求值"

5 goland is good:

-------------------------------------------------------------------------

https://golang.org/doc/install

Download the Go distribution

Download Go Click here to visit the downloads page

Official binary distributions are available for the FreeBSD (release 8-STABLE and above), Linux, Mac OS X (10.8 and above), and Windows operating systems and the 32-bit (386) and 64-bit (amd64) x86 processor architectures.

If a binary distribution is not available for your combination of operating system and architecture, try installing from source or installing gccgo instead of gc.

System requirements

Go binary distributions are available for these supported operating systems and architectures. Please ensure your system meets these requirements before proceeding. If your OS or architecture is not on the list, you may be able to install from source or use gccgo instead.

Operating system Architectures Notes

FreeBSD 9.3 or later amd64, 386 Debian GNU/kFreeBSD not supported
Linux 2.6.23 or later with glibc amd64, 386, arm, arm64,
s390x, ppc64le
CentOS/RHEL 5.x not supported.
Install from source for other libc.
macOS 10.8 or later amd64 use the clang or gcc that comes with Xcode for cgo support
Windows XP SP2 or later amd64, 386 use MinGW gcc. No need for cygwin or msys.

A C compiler is required only if you plan to use
cgo.
You only need to install the command line tools for
Xcode. If you have already
installed Xcode 4.3+, you can install it from the Components tab of the
Downloads preferences panel.

Install the Go tools

If you are upgrading from an older version of Go you must
first remove the existing version.

Linux, Mac OS X, and FreeBSD tarballs

Download the archive
and extract it into /usr/local, creating a Go tree in
/usr/local/go. For example:

tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz

Choose the archive file appropriate for your installation. For instance, if you are installing Go version 1.2.1 for 64-bit x86 on Linux, the archive you want is called go1.2.1.linux-amd64.tar.gz.

(Typically these commands must be run as root or through sudo.)

Add /usr/local/go/bin to the PATH environment variable. You can do this by adding this line to your /etc/profile (for a system-wide installation) or $HOME/.profile:

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

Installing to a custom location

The Go binary distributions assume they will be installed in /usr/local/go (or c:\Go under Windows), but it is possible to install the Go tools to a different location. In this case you must set the GOROOT environment variable to point to the directory in which it was installed.

For example, if you installed Go to your home directory you should add commands like the following to $HOME/.profile:

export GOROOT=$HOME/go1.X
export PATH=$PATH:$GOROOT/bin

Note: GOROOT must be set only when installing to a custom location.

Mac OS X package installer

Download the package file, open it, and follow the prompts to install the Go tools. The package installs the Go distribution to /usr/local/go.

The package should put the /usr/local/go/bin directory in your PATH environment variable. You may need to restart any open Terminal sessions for the change to take effect.

Windows

The Go project provides two installation options for Windows users (besides installing from source): a zip archive that requires you to set some environment variables and an MSI installer that configures your installation automatically.

MSI installer

Open the MSI file and follow the prompts to install the Go tools. By default, the installer puts the Go distribution in c:\Go.

The installer should put the c:\Go\bin directory in your PATH environment variable. You may need to restart any open command prompts for the change to take effect.

Zip archive

Download the zip file and extract it into the directory of your choice (we suggest c:\Go).

If you chose a directory other than c:\Go, you must set the GOROOT environment variable to your chosen path.

Add the bin subdirectory of your Go root (for example, c:\Go\bin) to your PATH environment variable.

Setting environment variables under Windows

Under Windows, you may set environment variables through the "Environment Variables" button on the "Advanced" tab of the "System" control panel. Some versions of Windows provide this control panel through the "Advanced System Settings" option inside the "System" control panel.

Test your installation

Check that Go is installed correctly by setting up a workspace and building a simple program, as follows.

Create your workspace directory, $HOME/go. (If you'd like to use a different directory, you will need to set the GOPATH environment variable.)

Next, make the directory src/hello inside your workspace, and in that directory create a file named hello.go that looks like:

package main

import "fmt"

func main() {
fmt.Printf("hello, world\n")
}

Then build it with the go tool:

$ cd $HOME/go/src/hello
$ go build

The command above will build an executable named hello in the directory alongside your source code. Execute it to see the greeting:

$ ./hello
hello, world

If you see the "hello, world" message then your Go installation is working.

You can run go install to install the binary into your workspace's bin directory or go clean to remove it.

Before rushing off to write Go code please read the How to Write Go Code document, which describes some essential concepts about using the Go tools.

Uninstalling Go

To remove an existing Go installation from your system delete the go directory. This is usually /usr/local/go under Linux, Mac OS X, and FreeBSD or c:\Go under Windows.

You should also remove the Go bin directory from your PATH environment variable. Under Linux and FreeBSD you should edit /etc/profile or $HOME/.profile. If you installed Go with the Mac OS X package then you should remove the /etc/paths.d/go file. Windows users should read the section about setting environment variables under Windows.

Getting help

For help, see the list of Go mailing lists, forums, and places to chat.

Report bugs either by running “go bug”, or manually at the Go issue tracker.

--------------------------------------------------

source ~/.bash_profile
 
 
  •  
 

SettingGOPATH

Graham Lyons edited this page 4 days ago · 20 revisions

The GOPATH environment variable specifies the location of your workspace. If no GOPATH is set, it is assumed to be $HOME/go on Unix systems and %USERPROFILE%\go on Windows. If you want to use a custom location as your workspace, you can set the GOPATH environment variable. This page explains how to set this variable on various platforms.

Unix systems

GOPATH can be any directory on your system. In Unix examples, we will set it to $HOME/work. Note that GOPATH must not be the same path as your Go installation. Another common setup is to set GOPATH=$HOME.

Bash

Edit your ~/.bash_profile to add the following line:

export GOPATH=$HOME/work

Save and exit your editor. Then, source your ~/.bash_profile.

source ~/.bash_profile

Note: Set the GOBIN path to generate a binary file when go install is run.

export GOBIN=$HOME/work/bin

Zsh

Edit your ~/.zshrc file to add the following line:

export GOPATH=$HOME/work

Save and exit your editor. Then, source your ~/.zshrc.

$ source ~/.zshrc

Windows

Your workspace can be located wherever you like, but we'll use C:\work in this example. Note that GOPATH must not be the same path as your Go installation.

  • Create folder at C:\work.
  • Right click on "Start" and click on "Control Panel". Select "System and Security", then click on "System".
  • From the menu on the left, select the "Advanced systems settings".
  • Click the "Environment Variables" button at the bottom.
  • Click "New" from the "User variables" section.
  • Type GOPATH into the "Variable name" field.
  • Type C:\work into the "Variable value" field.
  • Click OK.
2017 GitHub, Inc. Terms Privacy Security Status Help Contact GitHub API Training Shop Blog About没有符合的翻译结果!请确认选中的文本是完整的单词或句子 目前仅谷歌翻译支持汉译英 轻灵划译数据来源: 35,754
2017 GitHub,Inc .条款隐私安全状态帮助联系GitHub API培训店博客没有符合的翻译结果!请确认选中的文本是完整的单词或句子目前仅谷歌翻译支持汉译英轻灵划译数据来源:35754
轻灵划译
数据来源:

linux go with vscode的更多相关文章

  1. .Net Core Linux centos7行—vscode开发,linux部署运行

    前面搭建好啦linux运行环境,下面搭建windows下的开发环境.并完成调试 参考地址:https://www.microsoft.com/net/core#windows. 按照步骤来就好.安装. ...

  2. Linux下安装VSCode

    进行下载 64位的包:地址: https://code.visualstudio.com/docs/?dv=linux64&build=insiders 1.解压: tar -zxvf cod ...

  3. vscode在win10 / linux下的.vscode文件夹的配置 (c++/c)

    系统方面配置自行查找 linux: launch.json { // 使用 IntelliSense 了解相关属性. // 悬停以查看现有属性的描述. // 欲了解更多信息,请访问: https:// ...

  4. Linux下使用VsCode进行Qt开发环境搭建

    最近在Linux上搞Qt, vim环境还用不太习惯, QtCreator之前使用时莫名其妙崩溃然后丢失代码之后就被我彻底放弃了, 于是研究了一下用VsCode进行Qt开发. 首先是系统环境和下载安装包 ...

  5. linux下使用vscode和makefile搭建C++开发环境

    最近在linux上跑一些开源库做学习用, 顺手就搭了一下vscode的c++开发环境, 这里分享一下vscode进行C++开发的基本环境结构. 1. 首先是编辑器, vscode直接官网下载的, 后期 ...

  6. Linux下设置VSCode为默认的文本编辑器

    解决方法 执行一下命令 xdg xdg-mime default code.desktop text/plain Debian alternatives system sudo update-alte ...

  7. linux 下安装vscode

    下载安装包 https://code.visualstudio.com/docs/?dv=linux64_deb (注意是deb包) sudo dpkg -i code_1.18.1-15108573 ...

  8. vscode "find all references" 提示: no result found.

        vscode(visual studio code) 是微软推出的一款编辑器.免费,跨平台,最主要是轻便,消耗资源少, 成为码农阅读code的利器. vscode可以安装第三方的一些插件,满足 ...

  9. 基于Mono和VSCode打造轻量级跨平台IDE

      近期Visual Studio推出Mac版本号的消息迅速在技术圈里刷屏,当project师们最喜欢的笔记本电脑Mac,邂逅地球上最强大的集成开发环境Visual Studio的时候,会碰撞出如何精 ...

随机推荐

  1. 170502、linux下配置jdk8

    1.下载源码包jdk-8u45-linux-x64.tar.gz(省略) 2.解压 tar -zxvf jdk-8u45-linux-x64.tar.gz 3.配置jdk vi /etc/profil ...

  2. Piwik网站访问统计软件安装

    Piwik是一个PHP和MySQL的开放源代码的Web统计软件. 它给你一些关于你的网站的实用统计报告,比如网页浏览人数, 访问最多的页面, 搜索引擎关键词等等… Piwik拥有众多不同功能的插件,你 ...

  3. Codeforces Round #426 (Div. 2)A题&&B题&&C题

    A. The Useless Toy:http://codeforces.com/contest/834/problem/A 题目意思:给你两个字符,还有一个n,问你旋转n次以后从字符a变成b,是顺时 ...

  4. zipline风险指标计算 (empyrical模块)

    概述 量化中,我们经常会遇到各种量化指标的计算,对于zipline来说,也会对这部分计算进行处理,由于指标计算的通用性比较强,所以,zipline单独封装了 empyrical 这个模块,可以处理类似 ...

  5. qemu网络虚拟化之数据流向分析二

    2016-09-27 上篇文章大致介绍了qemu网络虚拟化相关的数据结构,本篇就结合qemu-kvm源代码分析下各个数据结构是如何初始化以及建立联系的. 这里还是分为三个部分: 1.Tap设备区 2. ...

  6. python定义函数时默认参数注意事项

    如果在调用一个函数时,没有传递默认参数,则函数内的默认参数是对函数的默认参数属性__defaults__的引用, 如 def func(arg1=[]): arg1.append(2) 调用func时 ...

  7. Flask之请求和响应

    from flask import Flask from flask import request from flask import render_template from flask impor ...

  8. Linux命令(补充)

    1.查看已启动服务的端口: netstat -tulnp |grep 80 ss -tulnp|grep 80 2.查看全部已启动的端口:netstat -tulnp 3.查看当前目录:pwd 4.关 ...

  9. ALV tree标准DEMO

    BCALV_TREE_01 ALV 树控制:构建层次树 BCALV_TREE_02 ALV 树控制:事件处理 BCALV_TREE_03 ALV 树控制:使用自己的上下文菜单 BCALV_TREE_0 ...

  10. python 学习笔记(十四)有依赖关系的接口开发

    接口开发中存在很多有依赖关系的接口,例如:BBS中发帖的时候就需要进行校验用户是否登录,那么此时发帖的接口就与用户登录接口有依赖关系.在发帖时就需要先获取用户的session,与当前登录用户进行校验对 ...