Skip to content

aahmed7/golang_practice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GOLANG PRACTICE

Running a go module directly

go run <module-path>/<module-name>.go

Building a go module

For building a go module, the module must be inside the directory defined by GOPATH env variable, where GOPATH has the following structure:

$GOPATH
├── bin
├── lib
└── src

and modules are located inside the 'src' directory Run the following command to build a module

go build <module-name>

This will generate a binary calling directory.

Installing a go module

Installing a go module refers to installing it to bin directory in the GOPATH. To install a module:

go install <module-name>

GOPATH settings update

Golang needs to run inside path pointed by GOPATH env variable. To update the GOPATH to use the current directory, run the following command:

On linux, source the file:

. set_gopath.sh

On Windows, run:

.\set-gopath.ps1

GOPATH env variable can have multiple paths, so its better to add the workspace to GOPATH in .profile in linux and env variables in Windows

Ownership

This work has been taken from multiple sources, combined into one for a quick study. I do not take ownership for any part, except for the bash and pwsh scripts

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages