部署go环境

栏目: Go · 发布时间: 7年前

内容简介:直接下载go的安装包下载地址,1.11进行安装安装完成后,在终端验证是否安装成功.为了保证相关文件系统在任何位置都能使用,你还需要添加以下内容:

1、 go 环境变量

  • GOROOT go在电脑中的安装位置
  • GOPATH go项目存放目录
  • GOBIN go编译的安装位置,默认为$GOROOT/bin

2、安装go

mac

直接下载go的安装包下载地址,1.11进行安装

安装完成后,在终端验证是否安装成功.

$~ go version
go version go1.11 darwin/amd64

为了保证相关文件系统在任何位置都能使用,你还需要添加以下内容:

$~ echo "export PATH=$PATH:$GOROOT/bin" > ~/.bash_profile
$~ echo "export GOPATH=/Users/xxx/go" > ~/.bash_profile
$~ echo "export PATH=$PATH:$GOROOT/bin" > ~/.bash_profile
$~ source ~/.bash_profile

查看go环境变量

$~ go env
GOPATH="/Users/xxx/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"

在GOPATH目录为src,bin,pkg三个子目录

  • src,源码目录
  • bin,编译后的可执行文件
  • pkg, 编译后的包文件

在src下新建一个hello.go

package main

import "fmt"

func main() {
    fmt.Println("hello, golang")
}

验证输出

$~ go run hello.go
hello, golang

输出hello, golang,go安装成功。liunx,windows没有,我没用这两个系统。


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

JavaScript and Ajax for the Web, Sixth Edition

JavaScript and Ajax for the Web, Sixth Edition

Tom Negrino、Dori Smith / Peachpit Press / August 28, 2006 / $24.99

Book Description Need to learn JavaScript fast? This best-selling reference’s visual format and step-by-step, task-based instructions will have you up and running with JavaScript in no time. In thi......一起来看看 《JavaScript and Ajax for the Web, Sixth Edition》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

URL 编码/解码
URL 编码/解码

URL 编码/解码

html转js在线工具
html转js在线工具

html转js在线工具