Ubuntu-go Language Environment variables

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

1, environment variable Golang official website Introduction

$GOROOT
the root of the Go tree, often $HOME/go . This defaults to the parent of the directory where is all.bash run. If you choose not to set $GOROOT , you must run gomake instead of make or when gmake developing Go programs using the Conventional makefiles.
$GOROOT_FINAL
The value assumed by installed binaries, and scripts when are not
$GOROOT set. It defaults to the value used for $GOROOT . If you want to build the Go tree on one location but move it elsewhere after the build, set to the $GOROOT_FINAL eventual Locati On.
$GOOSand $GOARCH
The name of the target operating system and compilation architecture. These default to the values of $GOHOSTOSand $GOHOSTARCHrespectively (described below).

Choices for $GOOS is linux , freebsd darwin (Mac OS X 10.5 or 10.6), and windows (Windows, an incomplete port). Choices for $GOARCH is amd64 (64-bit x86, the most mature port), 386 (32-bit x86), and arm (32-bit ARM, an incomplete PO RT). The valid combinations of and are $GOOS $GOARCH :

$GOOS $GOARCH
darwin 386
darwin amd64
freebsd 386
freebsd amd64
linux 386
linux amd64
linux arm Incomplete
windows 386 Incomplete
$GOHOSTOSand $GOHOSTARCH
The name of the host operating system and compilation architecture. These default to the local system ' s operating system and architecture.

Valid Choices $GOOS $GOARCH is the same as for and, listed above. The specified values must is compatible with the local system. For example, you should the not set to on an $GOHOSTARCH arm x86 system.

$GOBIN
The location
where binaries would be installed. The default is $GOROOT/bin . After installing, you'll want to arrange-to-add this directory $PATH to your and so can use the tools.
$GOARM(ARM, Default=6)
The
ARM architecture version The Run-time libraries should target. ARMV6 cores has more efficient synchronization primitives. Setting to $GOARM 5 would compile the Run-time libraries using just SWP instructions that work on older architectures as we LL. Running V6 code on an older core would cause an illegal instruction trap.

$GOARCH  and  $GOOS  identify the  target  environment, not the environment is running on. In effect, your is always cross-compiling. By architecture, we mean the kind of binaries, the target environment can Run:an x86-64 system running a 32-bit-only Operating system must set 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

Export goroot= $HOME/goexport goarch=386export goos=linux

2. Configure in Ubuntu

1) environment variable configuration file

InUbuntuYou can set environment variables in the following files
1、/etc/profile:When you log on,The first file used by the operating system to customize the user environment,This file sets the environment information for each user of the system,When a user logs on for the first time,The file is executed.
2、/etc/environment:The second file that the operating system uses when logging on,The system is reading your own ProfileAgo,Set environment variables for environment files.
3、~/.bash_profile:The third file to use when you log in is. profileFile,Each user can use this file to enter a specificShellInformation,When a user logs on,The file executes only once!By default,He set some environment to change the game amount,Executes the user's. BASHRCFile./ETC/BASHRC:For each runBash ShellThe user executes this file.WhenBash ShellWhen it is opened,The file is read.
4、~/.BASHRC:This file contains the files dedicated to yourBash ShellOfBashInformation,When you log on and each time you open a newShellWhen,The file is read.

Priority of several environment variables

1>2>3

2) Start the configuration, which is configured for use only by this user

liuxing@liuxing-o-e-m:~$ gedit ~/.BASHRC

Add in the back

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


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.