Golang gc: Difference between revisions

From wikinotes
Line 3: Line 3:
= run =
= run =
<blockquote>
<blockquote>
<code>go run</code> is a convenience tool that builds/runs an executable.<br>
<code>go run</code> is a convenience tool that builds/runs an executable.
it accepts all of the same build-flags as <code>go build</code>.


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
Line 12: Line 11:
go run main.go lib.go ... # compile only these files, and run detected 'main()' method
go run main.go lib.go ... # compile only these files, and run detected 'main()' method
go run some/package      # compile a specific package
go run some/package      # compile a specific package
</syntaxhighlight>
It accepts all of the same build-flags as <code>go build</code>,<br>
which includes some validation tools.
<syntaxhighlight lang="bash">
go run -race .  # compile/run, and detect race conditions
</syntaxhighlight>
</syntaxhighlight>
</blockquote><!-- run -->
</blockquote><!-- run -->

Revision as of 01:08, 19 June 2022

This page documents the builtin golang compilation tools.

run

go run is a convenience tool that builds/runs an executable.

go run .                  # compile package at cwd, and run it's 'main()' method
go run . --help           # cli params for the program can be passed to go run

go run main.go lib.go ... # compile only these files, and run detected 'main()' method
go run some/package       # compile a specific package

It accepts all of the same build-flags as go build,
which includes some validation tools.

go run -race .  # compile/run, and detect race conditions

build

clean

install