码迷,mamicode.com
首页 > 其他好文 > 详细

go环境和编辑器配置

时间:2019-01-06 00:07:16      阅读:513      评论:0      收藏:0      [点我收藏+]

标签:gyp   下载文件   不同   不为   g++   分享   虚拟   设置   rmi   

go环境的安装

在linux虚拟机中安装分两步

  解压go包到/usr/local下

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

  cp go1.10.linux-amd64.tar.gz /usr/local

  tar zxvf go1.10.linux-amd64.tar.gz

  根据个人虚拟机目录不同,设置环境变量

  export GOROOT=/path/to/go/

  export PATH=$PATH:$GOROOT/bin/

  export GOPATH=/home/user/project/go

 

windows下安装直接下载文件一路next就可以了,https://golang.google.cn/doc/install?download=go1.11.4.windows-amd64.msi,设置环境变量使得go.exe能被找到

goland编辑器的安装

去 https://www.jetbrains.com/go/ 下载goland编辑器,goland并非免费,需要激活。激活有很多种方式,我找到一个激活码,可以使用一段时间 

 

技术分享图片
G91XMO9AVI-eyJsaWNlbnNlSWQiOiJHOTFYTU85QVZJIiwibGljZW5zZWVOYW1lIjoic29uZyB3YW5nIiwiYXNzaWduZWVOYW1lIjoiIiwiYXNzaWduZWVFbWFpbCI6IiIsImxpY2Vuc2VSZXN0cmljdGlvbiI6IkZvciBlZHVjYXRpb25hbCB1c2Ugb25seSIsImNoZWNrQ29uY3VycmVudFVzZSI6ZmFsc2UsInByb2R1Y3RzIjpbeyJjb2RlIjoiSUkiLCJwYWlkVXBUbyI6IjIwMTktMDMtMDYifSx7ImNvZGUiOiJSUzAiLCJwYWlkVXBUbyI6IjIwMTktMDMtMDYifSx7ImNvZGUiOiJXUyIsInBhaWRVcFRvIjoiMjAxOS0wMy0wNiJ9LHsiY29kZSI6IlJEIiwicGFpZFVwVG8iOiIyMDE5LTAzLTA2In0seyJjb2RlIjoiUkMiLCJwYWlkVXBUbyI6IjIwMTktMDMtMDYifSx7ImNvZGUiOiJEQyIsInBhaWRVcFRvIjoiMjAxOS0wMy0wNiJ9LHsiY29kZSI6IkRCIiwicGFpZFV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6ss+Ga+aDY6f/qXZuUCEUOH3QUNbbCUlviSz6+GiRnt1kA9N2Qachl+2yBfaqUqr8h7Z2gsx5LcIf5kYNsqJ0GavXTVyWh7PYiKX4bs354ZQLUwwa/cG++2+wNWP+HtBhVxMRNTdVhSm38AknZlD+PTAsWGu9GyLmhti2EnVwGybSD2Dxmhxk3IPCkhKAK+pl0eWYGZWG3tJ9mZ7SowcXLWDFAk0lRJnKGFMTggrWjV8GYpw5bq23VmIqqDLgkNzuoog==
激活码

 

go的第一个hello world程序,hello.go

// 包名为main就是可执行文件,包名不为main就是一个普通的包或者库,不能执行
package main

// 导入需要的包
import(
    "fmt"
)

// func main是程序入口
func main(){
    fmt.Println("hello, world!")
}

使用go run hello.go运行它,输出hello,world

调试工具delve的安装

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

用goland创建项目并运行

  可以参考这个博文 https://www.apa70.com/article/30.html 写的很详细 

 

go环境和编辑器配置

标签:gyp   下载文件   不同   不为   g++   分享   虚拟   设置   rmi   

原文地址:https://www.cnblogs.com/wangdafeng/p/10226637.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!