`
deepfuture
  • 浏览: 4432024 次
  • 性别: Icon_minigender_1
  • 来自: 湛江
博客专栏
073ec2a9-85b7-3ebf-a3bb-c6361e6c6f64
SQLite源码剖析
浏览量:80369
1591c4b8-62f1-3d3e-9551-25c77465da96
WIN32汇编语言学习应用...
浏览量:70858
F5390db6-59dd-338f-ba18-4e93943ff06a
神奇的perl
浏览量:104119
Dac44363-8a80-3836-99aa-f7b7780fa6e2
lucene等搜索引擎解析...
浏览量:287647
Ec49a563-4109-3c69-9c83-8f6d068ba113
深入lucene3.5源码...
浏览量:15151
9b99bfc2-19c2-3346-9100-7f8879c731ce
VB.NET并行与分布式编...
浏览量:68387
B1db2af3-06b3-35bb-ac08-59ff2d1324b4
silverlight 5...
浏览量:32588
4a56b548-ab3d-35af-a984-e0781d142c23
算法下午茶系列
浏览量:46293
社区版块
存档分类
最新评论

ubuntu-go语言环境变量

 
阅读更多

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 $GOHOSTARCHrespectively (described below).

Choices for $GOOS are linuxfreebsddarwin (Mac OS X 10.5 or 10.6), and windows (Windows, an incomplete port). Choices for $GOARCHare 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 shellbash信息,当登录时以及每次打开新的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 安装 Go 语言环境教程 #### 环境准备 在开始之前,请确保你的 Ubuntu 版本为 16.04 或更高版本。本文档将引导你完成 Go 语言环境的安装过程,并介绍如何配置必要的依赖,如 Supervisor、MySQL、Redis ...

    go语言PDF---golang

    Go语言,又称为Golang,是由Google设计的一种开放源代码的编程语言。它具备高效性、简洁性和易用性的特点,在现代软件开发领域备受青睐。以下是Go语言的一些关键特性: 1. **快速编译**: Go语言能在几秒钟内编译...

    Ubuntu安装Go语言运行环境

    Go语言,又称为Golang,是由Google开发的一种静态类型的、编译型的、并发型的、垃圾回收的编程语言,特别适合于构建高效、可扩展的网络和分布式系统。 首先,为了获取Go语言的源代码,我们需要安装Mercurial...

    ubuntu20.04离线安装gcc.zip

    6. **设置环境变量**:为了让系统能够找到新安装的GCC,需要更新`PATH`环境变量: ``` echo 'export PATH=/usr/local/gcc-9/bin:$PATH' >> ~/.bashrc source ~/.bashrc ``` 7. **验证安装**:最后,通过运行`...

    centos/ubuntu安装go环境

    Go语言,又称为Golang,是由Google开发的一种静态类型、编译型、并发型且具有垃圾回收功能的编程语言。它以其简洁的语法、高效的性能以及内置的并发支持而受到开发者们的青睐。在没有网络连接或者网络不稳定的情况下...

    ubuntu1804环境下fabric-1.4.6环境部署.docx

    Hyperledger Fabric 是用 Go 语言编写的,因此需要先安装 Go 语言环境。 **步骤:** 1. **下载 Go 安装包:** ```bash wget https://studygolang.com/dl/golang/go1.13.4.linux-amd64.tar.gz ``` 2. **解压...

    ansible-role-golang:在Mac和Linux(Ubuntu,CentOS)上安装Go编程语言和软件包

    在本案例中,“ansible-role-golang”就是一个专门为安装Go语言设计的Role。 1. **安装Ansible**: 在开始之前,确保你的系统已经安装了Ansible。如果尚未安装,可以通过Python的包管理器pip进行安装,例如在...

    Ubuntu18.04 LTS搭建GO语言开发环境过程解析

    一、下载Go语言安装包 官网下载地址:https://golang.org/dl/,使用tar命令将档案包解压到/usr/local目录中: sudo tar -C /usr/local -xzf go1.11.5.linux-amd64.tar.gz 二、添加环境变量和工作变量到系统环境中 先...

    Go语言入门指南.docx

    ### Go语言入门指南知识点概述 #### 一、Go语言起源与发展 - **创造者**: Go语言由Ken Thompson(Unix及B语言之父)、Rob Pike(UTF-8发明者及Go语言设计领头人)、Robert Griesemer(V8引擎开发者)共同创立。...

    Ubuntu下安装Go语言开发环境及编辑器的相关配置

    综上所述,本文详细介绍了在Ubuntu下安装和配置Go语言开发环境的方法,包括安装Go语言、配置环境变量、组织工作目录、创建并运行Go应用、配置编辑器支持以及使用Eclipse进行Go语言开发等内容。这些步骤对于初学者来...

    GO语言学习之配置篇

    在深入探讨GO语言的学习之前,我们首先需要搭建一个适合编程的环境。本篇文章将主要讲解如何在不同操作系统上,包括Windows、Mac OS以及Linux(Ubuntu 16.04和CentOS 7.2),安装虚拟机、配置操作系统以及安装和配置...

    Ubuntu环境搭建Go语言开发环境

    更多内容,请查看博客原文:Ubuntu环境搭建Go语言开发环境 下载Golang安装文件 官方下载页面:https://golang.org/dl/ 也可以到国内下载地址下载:https://studygolang.com/dl 我下载的版本是go1.12.14,下载到/usr/...

    go1.9.2.linux-amd64.tar.gz 官网最新golang的Linux安装包

    Go语言,简称Golang,是由Google开发的一种静态类型的、编译式的、并发的、垃圾回收的、C/C++风格的编程语言。Go语言的设计目标是提高开发者的生产效率,同时保持系统级编程的性能。在本文中,我们将详细探讨Go ...

    go语言开发环境安装配置

    Go语言,也称为Golang,是由Google开发的一种静态类型的、编译式的、并发型且具有垃圾回收功能的编程语言。它的设计目标是提高开发效率,同时保持程序的高性能和安全性。在本文中,我们将深入探讨如何在Linux和...

    Go-goveralls-Go集成Coveralls.io代码覆盖率持续跟踪系统

    首先,你需要设置`COVERALLS_TOKEN`环境变量,这是`Coveralls.io`为你的项目分配的唯一标识。然后,运行如下命令: ```bash goveralls -service=ci -coverprofile=coverage.out -repotoken $COVERALLS_TOKEN ``` ...

    如何在 ubuntu linux 上配置 go 语言的 qt 开发环境

    总的来说,配置Ubuntu Linux上的Go语言Qt开发环境涉及安装Go语言的Qt绑定包、设置环境变量以及选择合适的IDE。遵循上述步骤,你将能够顺利搭建起一个高效的开发环境,从而更好地进行Go语言和Qt的结合开发。记住,...

    ubuntu 18 安装go.rar

    在Ubuntu 18.04上安装Go编程语言是一个简单的过程,主要分为几个步骤,包括下载Go的源码包或二进制包、配置环境变量以及验证安装。下面将详细介绍这个过程。 首先,你需要访问Go的官方网站(https://golang.org/dl/...

    golang_Web开发(1).pdf

    GOROOT 是 Go 语言的安装目录,GOBIN 是 Go 语言的可执行文件目录,PATH 是系统的环境变量。这些环境变量的设置可以方便地使用 Go 语言。 判断操作系统的位数 在安装 Go 语言之前,需要判断操作系统的位数。Windows...

Global site tag (gtag.js) - Google Analytics