In this repo, you will learn more about about Golang.
The Go
language was created by Google
for system programming and has since been extended to applications. It is an imperative and concurrent language. Its compilation speed (due to the simplicity of its syntax) makes it sometimes used as a scripting language.
Go
aims to make large-scale programming easier
and faster
: because of its simplicity
, it can be used for writing applications
, scripts
or large systems
.
This simplicity is also necessary to ensure the maintenance and evolution of programs over several generations of developers.
If he also aims for speed of execution, which is essential for system programming, he considers multithreading to be the most robust way of ensuring this speed on today's processors while making maintenance easy by separating simple tasks that are executed independently in order to avoid creating "gas factories". This design also allows operation without rewriting on multi-core architectures by immediately exploiting the corresponding power increase.
-
Install Go on your machine
- If you are using a MacBook, use
brew install go
- If you are using a MacBook, use
-
If you already have Go installed, feel free to skip installation or find the section below called Upgrading To Go 1.13.
following commands:
which go
/usr/local/go
go version
go version go1.13.1 darwi/amd64
-
Go checks for a certain environment variable,
GOPATH
when executing a Go program. We need to update our bash_profile to help Go find where our files will live. -
In a code editor, open up your
.bash_profile
which should be located in your home directory. -
Add the following lines to the bottom of the file (or wherever you export your PATH environment variables)
export GOPATH=$HOME/go
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOBIN
-
Restart your terminal
-
Run the following commands and verify you see similar output
echo $PATH
..../usr/local/go/bin:
echo $GOPATH
/Users/brennamartenson/go
We just told Go that whenever we run a Go command in our terminal (ie: go run main.go
), it should look for those files in the GOPATH, which typically defaults to /Users/yourusername/go
.
-
Navigate to your home directory and create a
go
directory withmkdir go
. -
Change into the go directory with
cd go
-
Clone the repo for this course into the
go
directory.
git clone https://github.com/svngoku/go-for-js-devs.git
-
Change into the
cd go-for-js-devs
directory -
Run
go run main.go
-
If all went well, you should see
"Hello World!"
-
Init the project with this command
go mod tidy
at the source of the project.
- Verify you do have Go installed in the first place:
go version
go version go1.12.1 darwin/amd64
- Uninstall Go
sudo rm -rf /usr/local/go
- Verify Go was uninstalled
go version
-bash: go: command not found
- Visit golang.org/dl to install the latest Go.