Skip to content

svngoku/go-for-ts-devs

Repository files navigation

Go for TypeScript Developers

In this repo, you will learn more about about Golang.

Story

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.

Installation

  • Install Go on your machine

    • If you are using a MacBook, use brew install go
  • Visit the golang

  • 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

Modify Your PATH

  1. 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.

  2. In a code editor, open up your .bash_profile which should be located in your home directory.

  3. 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

Verify These Updates

  1. Restart your terminal

  2. Run the following commands and verify you see similar output

echo $PATH
 ..../usr/local/go/bin: 

echo $GOPATH
 /Users/brennamartenson/go

Create a go workspace

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.

  1. Navigate to your home directory and create a go directory with mkdir go.

  2. Change into the go directory with cd go

  3. Clone the repo for this course into the go directory.

git clone https://github.com/svngoku/go-for-js-devs.git

Verify Everything Is Good To GO 😉

  1. Change into the cd go-for-js-devs directory

  2. Run go run main.go

  3. If all went well, you should see "Hello World!"

  4. Init the project with this command go mod tidy at the source of the project.

Upgrading to Go 1.13

  1. Verify you do have Go installed in the first place:
go version 
go version go1.12.1 darwin/amd64
  1. Uninstall Go
sudo rm -rf /usr/local/go
  1. Verify Go was uninstalled
go version
-bash: go: command not found
  1. Visit golang.org/dl to install the latest Go.

About

Introduction to Go for Typescript kids

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages