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-16.04.6-desktop-i386
ubuntu-14.04.3-desktop-i386.rar
ubuntu-20.04-desktop-amd64(百度网盘) (ISO)(百度网盘)(百度网盘)
ubuntu-base-16.04-core-armhf.tar.gz ubuntu-base-16.04-core-armhf.tar.gz
ubuntu-14.04.3-desktop-amd64 官方下载版本
ubuntu-14.04-desktop-i386.part14
百度云资源下载ubuntu-14.04-desktop-amd64.iso;
ubuntu-14.04.6-desktop-amd64.iso,官方提供iso
ubuntu-16.04.3 镜像种子(ubuntu-16.04.3-desktop-amd64.zip)
ubuntu-22.04-live-server-arm64.iso https://releases.ubuntu.com/jammy/
百度承不欺我,ubuntu-16.04.6-desktop-amd64.iso镜像文件,挣点积分换流量
放置到`openarkcompiler/tools`目录,打开`openarkcompiler/build/config/BUILDCONFIG.gn`文件,将`GN_C_COMPILER`、`GN_CXX_COMPILER`和`GN_AR`三个变量配置为Clang编译器所在路径,例如: ``` GN_C_COMPILER = "$...
ubuntu-10.04.4-desktop-i386.iso
ubuntu-20.04.3-desktop-amd64,共2部分,此为第1部分。
ubuntu-18.04.6-server-arm64.iso ubuntu arm64 aarch64位系统 ubuntu for arm64 ubuntu for aarch64
ubuntu-16.04.4-desktop-amd64.iso百度网盘下载地址,古人诚不我欺。
ubuntu-18.04.1-desktop-amd64.iso百度网盘下载地址,自己整理,诚不欺人。
ubuntu-14.04.5-desktop-amd64 官方下载版本
最新版的Linux虚拟机 ubuntu-18.04-desktop-amd64,有需要可以下载哦
ubuntu-14.04-desktop-amd64 官方下载版本