go环境搭建
1 首先在https://www.golangtc.com/download 上下载windows或者Linux的版本
2 下载后双击进行安装,可以自己选择安装路径。然后将安装路径的bin文件夹路径加入到系统PATH中去。在cmd中执行go version可以正常显示版本则表示安装成功
3 新建环境变量GOROOT, 设置值为安装路径的bin文件。新建环境变量GOPATH,设置值为放置go文件的目录
在Linux下还可用通过命令行的方式进行安装
1 获取最新的版本路径
add-apt-repository ppa:longsleep/golang-backports
2 更新apt库
apt-get update
3 安装go
sudo apt-get install golang-go
安装完后通过go version查看go的版本。go env查看GOPATH等设置
4 设置环境变量
在~/.bashrc 添加环境变量
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
source ~./bashrc
使配置生效
编译器goland配置
1 在https://www.jetbrains.com/go/?fromMenu下载goland软件进行安装
2 破解goland
下载JetbrainsCrack-2.8-release-enc并拷贝到goland安装目录的bin文件下。然后修改pycharm64.exe.vmoptions和pycharm.exe.vmoptions文件。在文件后面添加-javaagent:D:\PyCharm 2018.1.4\bin\JetbrainsCrack-2.8-release-enc.jar
打开goland然后输入如下的激活码
ThisCrackLicenseId-{
"licenseId":"11011",
"licenseeName":"微信公众号",
"assigneeName":"裸睡的猪",
"assigneeEmail":"1113449881@qq.com",
"licenseRestriction":"",
"checkConcurrentUse":false,
"products":[
{"code":"II","paidUpTo":"2099-12-31"},
{"code":"DM","paidUpTo":"2099-12-31"},
{"code":"AC","paidUpTo":"2099-12-31"},
{"code":"RS0","paidUpTo":"2099-12-31"},
{"code":"WS","paidUpTo":"2099-12-31"},
{"code":"DPN","paidUpTo":"2099-12-31"},
{"code":"RC","paidUpTo":"2099-12-31"},
{"code":"PS","paidUpTo":"2099-12-31"},
{"code":"DC","paidUpTo":"2099-12-31"},
{"code":"RM","paidUpTo":"2099-12-31"},
{"code":"CL","paidUpTo":"2099-12-31"},
{"code":"PC","paidUpTo":"2099-12-31"}
],
"hash":"2911276/0",
"gracePeriodDays":7,
"autoProlongated":false}
3 打开goland选择setting, 设置GOROOT和GOPATH。参照前面的环境变量设置值
4 代码测试。注意package名称为main
package main
func test(){
print("hello world again\n")
}
func main(){
test()
println("hello world")