Go Development and Execution Environment: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 6: Line 6:


=Environment Variables=
=Environment Variables=
{{External|https://pkg.go.dev/cmd/go#hdr-Environment_variables}}
{{Internal|Go Environment Variables|Go Environment Variables}}
==<tt>GOPATH</tt>==
<FONT COLOR=DARKKHAKI>The <code>GOPATH</code> environment variable defines the [[Go_Language_Modularization#Workspaces|workspace]] directory. Go tools assume that your code is under the path designated by <code>GOPATH</code>. Used to search for packages during compilation, when packages are being [[Go_Language_Modularization#Importing_Packages|imported]].</font>
 
To display the value, as seen by the Go runtime, execute:
<syntaxhighlight lang='bash'>
go env GOPATH
</syntaxhighlight>
For documentation on <code>GOPATH</code>, execute:
<syntaxhighlight lang='bash'>
go help gopath
</syntaxhighlight>
 
==<tt>GOROOT</tt>==
<font color=darkkhaki>Used to search for packages during compilation, when packages are being [[Go_Language_Modularization#Importing_Packages|imported]].</font>
To display the value, as seen by the Go runtime, execute:
<syntaxhighlight lang='bash'>
go env GOROOT
</syntaxhighlight>
==<tt>GO111MODULE</tt>==
{{External|https://go.dev/ref/mod#mod-commands}}
Controls whether the [[Go_Tool#Overview|<code>go</code> tool]] runs in module-aware mode or GOPATH mode. May be "off", "on" or "auto".


=Compilation=
=Compilation=

Revision as of 20:40, 7 September 2023

Internal

Overview

The go Tool

go is a tool used to manage source code. More details:

go

Environment Variables

Go Environment Variables

Compilation

go build

Execution

go run

TODO

Deplete, merge and delete Go Concepts - Runtime