Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

Initialize a module:

go mod init example.com/<module_name>

In order to execute some code, it must be coded inside the package name as "main" and execute inside it's terminal:

go run .

Update dependencies

go mod tidy

This command won't work if there's any existing locally referenced module. (Greetings exemplifies this case) To next command works around referencing local modules:

go mod edit -replace example.com/<module_name>=../<module_name>

In this case the locally referenced module is in the parent directory After that, executing:

go mod tidy

Will update the dependency to the local module instead of looking it up on the online base.

Testing

To execute a testing script you must use the command:

go test

Or if you want to use the verbose flag to view the output of every function:

go test -v

Build and Install

To build an application:

go build

Inside the terminal of the module you want to build as your main application You can also add the built program to the executable programs inside your machine by "installing" it This commands will add the executable to the env variable PATH First wee need to know where are the installed executables estored by Go by default:

go list -f '{{.Target}}'

The commando will show you the route where the executable will be stored once installed. We need the base directory for the next command:

set PATH=%PATH%;<bin_directory>

Where bin directory is the directory shown by the last command Now executing:

go install

The previously generated executable file will be stored in the /bin directory, hence callable from anywhere in your system!

About

A series of GoLang tutorials based on the language documentation basic projects. Essential for programmers using this tool for the first time.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages