1、环境变量GOLANG官网介绍
$GOROOT
The root of the Go tree, often $HOME/go
. This defaults to the parent of the directory where all.bash
is run. If you choose not to set$GOROOT
, you must run gomake
instead of make
or gmake
when developing Go programs using the conventional makefiles.
$GOROOT_FINAL
The value assumed by installed binaries and scripts when $GOROOT
is not set. It defaults to the value used for $GOROOT
. If you want to build the Go tree in one location but move it elsewhere after the build, set $GOROOT_FINAL
to the eventual location.
$GOOS
and $GOARCH
The name of the target operating system and compilation architecture. These default to the values of $GOHOSTOS
and $GOHOSTARCH
respectively (described below).
Choices for $GOOS
are linux
, freebsd
, darwin
(Mac OS X 10.5 or 10.6), and windows
(Windows, an incomplete port). Choices for $GOARCH
are amd64
(64-bit x86, the most mature port), 386
(32-bit x86), and arm
(32-bit ARM, an incomplete port). The valid combinations of$GOOS
and $GOARCH
are:
$GOOS
$GOARCH
|
darwin |
386 |
|
darwin |
amd64 |
|
freebsd |
386 |
|
freebsd |
amd64 |
|
linux |
386 |
|
linux |
amd64 |
|
linux |
arm |
incomplete |
|
windows |
386 |
incomplete |
$GOHOSTOS
and $GOHOSTARCH
The name of the host operating system and compilation architecture. These default to the local system's operating system and architecture.
Valid choices are the same as for $GOOS
and $GOARCH
, listed above. The specified values must be compatible with the local system. For example, you should not set $GOHOSTARCH
to arm
on an x86 system.
$GOBIN
The location where binaries will be installed. The default is $GOROOT/bin
. After installing, you will want to arrange to add this directory to your $PATH
, so you can use the tools.
$GOARM
(arm, default=6)
The ARM architecture version the run-time libraries should target. ARMv6 cores have more efficient synchronization primitives. Setting$GOARM
to 5 will compile the run-time libraries using just SWP instructions that work on older architectures as well. Running v6 code on an older core will cause an illegal instruction trap.
Note that $GOARCH
and $GOOS
identify the target environment, not the environment you are running on. In effect, you are always cross-compiling. By architecture, we mean the kind of binaries that the target environment can run: an x86-64 system running a 32-bit-only operating system must set GOARCH
to 386
, not amd64
.
If you choose to override the defaults, set these variables in your shell profile ($HOME/.bashrc
, $HOME/.profile
, or equivalent). The settings might look something like this
export GOROOT=$HOME/go
export GOARCH=386
export GOOS=linux
2、在ubuntu中配置
1)环境变量配置文件
在Ubuntu中有如下几个文件可以设置环境变量
1、/etc/profile:在登录时,操作系统定制用户环境时使用的第一个文件,此文件为系统的每个用户设置环境信息,当用户第一次登录时,该文件被执行。
2、/etc/environment:在登录时操作系统使用的第二个文件,系统在读取你自己的profile前,设置环境文件的环境变量。
3、~/.bash_profile:在登录时用到的第三个文件是.profile文件,每个用户都可使用该文件输入专用于自己使用的shell信息,当用户登录时,该 文件仅仅执行一次!默认情况下,他设置一些环境变游戏量,执行用户的.bashrc文件。/etc/bashrc:为每一个运行bash shell的用户执行此文件.当bash shell被打开时,该文件被读取.
4、~/.bashrc:该文件包含专用于你的bash shell的bash信息,当登录时以及每次打开新的shell时,该该文件被读取。
几个环境变量的优先级
1>2>3
2)开始配置,这里配置为仅本用户使用
liuxing@liuxing-O-E-M:~$ gedit ~/.bashrc
在后面加上
export GOROOT=$HOME/go
export GOBIN=$GOROOT/bin
export GOARCH=386
export GOOS=linux
export PATH=.:$PATH:$GOBIN
3)
liuxing@liuxing-O-E-M:~$ source ~/.bashrc
liuxing@liuxing-O-E-M:~$ 8g
gc: usage: 8g [flags] file.go...
flags:
-I DIR search for packages in DIR
-d print declarations
-e no limit on number of errors printed
-f print stack frame structure
-h panic on an error
-o file specify output file
-S print the assembly language
-V print the compiler version
-u disable package unsafe
-w print the parse tree after typing
-x print lex tokens
分享到:
相关推荐
### Ubuntu 安装 Go 语言环境教程 #### 环境准备 在开始之前,请确保你的 Ubuntu 版本为 16.04 或更高版本。本文档将引导你完成 Go 语言环境的安装过程,并介绍如何配置必要的依赖,如 Supervisor、MySQL、Redis ...
Go语言,又称为Golang,是由Google设计的一种开放源代码的编程语言。它具备高效性、简洁性和易用性的特点,在现代软件开发领域备受青睐。以下是Go语言的一些关键特性: 1. **快速编译**: Go语言能在几秒钟内编译...
Go语言,又称为Golang,是由Google开发的一种静态类型的、编译型的、并发型的、垃圾回收的编程语言,特别适合于构建高效、可扩展的网络和分布式系统。 首先,为了获取Go语言的源代码,我们需要安装Mercurial...
6. **设置环境变量**:为了让系统能够找到新安装的GCC,需要更新`PATH`环境变量: ``` echo 'export PATH=/usr/local/gcc-9/bin:$PATH' >> ~/.bashrc source ~/.bashrc ``` 7. **验证安装**:最后,通过运行`...
Go语言,又称为Golang,是由Google开发的一种静态类型、编译型、并发型且具有垃圾回收功能的编程语言。它以其简洁的语法、高效的性能以及内置的并发支持而受到开发者们的青睐。在没有网络连接或者网络不稳定的情况下...
Hyperledger Fabric 是用 Go 语言编写的,因此需要先安装 Go 语言环境。 **步骤:** 1. **下载 Go 安装包:** ```bash wget https://studygolang.com/dl/golang/go1.13.4.linux-amd64.tar.gz ``` 2. **解压...
在本案例中,“ansible-role-golang”就是一个专门为安装Go语言设计的Role。 1. **安装Ansible**: 在开始之前,确保你的系统已经安装了Ansible。如果尚未安装,可以通过Python的包管理器pip进行安装,例如在...
一、下载Go语言安装包 官网下载地址:https://golang.org/dl/,使用tar命令将档案包解压到/usr/local目录中: sudo tar -C /usr/local -xzf go1.11.5.linux-amd64.tar.gz 二、添加环境变量和工作变量到系统环境中 先...
### Go语言入门指南知识点概述 #### 一、Go语言起源与发展 - **创造者**: Go语言由Ken Thompson(Unix及B语言之父)、Rob Pike(UTF-8发明者及Go语言设计领头人)、Robert Griesemer(V8引擎开发者)共同创立。...
综上所述,本文详细介绍了在Ubuntu下安装和配置Go语言开发环境的方法,包括安装Go语言、配置环境变量、组织工作目录、创建并运行Go应用、配置编辑器支持以及使用Eclipse进行Go语言开发等内容。这些步骤对于初学者来...
在深入探讨GO语言的学习之前,我们首先需要搭建一个适合编程的环境。本篇文章将主要讲解如何在不同操作系统上,包括Windows、Mac OS以及Linux(Ubuntu 16.04和CentOS 7.2),安装虚拟机、配置操作系统以及安装和配置...
更多内容,请查看博客原文:Ubuntu环境搭建Go语言开发环境 下载Golang安装文件 官方下载页面:https://golang.org/dl/ 也可以到国内下载地址下载:https://studygolang.com/dl 我下载的版本是go1.12.14,下载到/usr/...
Go语言,简称Golang,是由Google开发的一种静态类型的、编译式的、并发的、垃圾回收的、C/C++风格的编程语言。Go语言的设计目标是提高开发者的生产效率,同时保持系统级编程的性能。在本文中,我们将详细探讨Go ...
Go语言,也称为Golang,是由Google开发的一种静态类型的、编译式的、并发型且具有垃圾回收功能的编程语言。它的设计目标是提高开发效率,同时保持程序的高性能和安全性。在本文中,我们将深入探讨如何在Linux和...
首先,你需要设置`COVERALLS_TOKEN`环境变量,这是`Coveralls.io`为你的项目分配的唯一标识。然后,运行如下命令: ```bash goveralls -service=ci -coverprofile=coverage.out -repotoken $COVERALLS_TOKEN ``` ...
总的来说,配置Ubuntu Linux上的Go语言Qt开发环境涉及安装Go语言的Qt绑定包、设置环境变量以及选择合适的IDE。遵循上述步骤,你将能够顺利搭建起一个高效的开发环境,从而更好地进行Go语言和Qt的结合开发。记住,...
在Ubuntu 18.04上安装Go编程语言是一个简单的过程,主要分为几个步骤,包括下载Go的源码包或二进制包、配置环境变量以及验证安装。下面将详细介绍这个过程。 首先,你需要访问Go的官方网站(https://golang.org/dl/...
GOROOT 是 Go 语言的安装目录,GOBIN 是 Go 语言的可执行文件目录,PATH 是系统的环境变量。这些环境变量的设置可以方便地使用 Go 语言。 判断操作系统的位数 在安装 Go 语言之前,需要判断操作系统的位数。Windows...