Go Tool: Difference between revisions

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


==<tt>run</tt>==
==<tt>run</tt>==
The <code>run</code> command compiles <code>.go</code> files and runs the executable.
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
cd $PROJECT_DIR
cd $PROJECT_DIR
go run ./src/main/main.go
go run ./src/main/main.go
</syntaxhighlight>
</syntaxhighlight>

Revision as of 01:30, 15 August 2023

Internal

Commands

build

The build command compiles and builds an executable.

cd ${PROJECT_DIR}
go build ./src/main/main.go

The command will create an executable named after the first source file, in this case main, and will place it by default in the ${PROJECT_DIR} directory.

doc

The doc command prints documentation for a package.

fmt

The fmt ("format") command formats source code files.

get

The get command downloads packages and installs them.

list

The list command lists all installed packages.

run

The run command compiles .go files and runs the executable.

cd $PROJECT_DIR
go run ./src/main/main.go