Giter Club home page Giter Club logo

go-basics's Introduction

go-basics

Go language basics

This section includes exercises and small projects which illustrate the basics of Go programming language. Things such as: types, data structures, functions, pointers, packages and others.

Section overview

Installation

Before trying any of these examples make sure to have the Go binary installed on your platform.

OSX:

# Install Homebrew

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Install Go

brew install go

Linux:

# Move into $HOME directory
cd ~

# Download the binary for your distribution
curl -O https://dl.google.com/go/go1.12.linux-amd64.tar.gz

# Verify that the downloaded binary is not corrupted. Check if the hash matches the one from downloads page
sha256sum go1.12.linux-amd64.tar.gz

# Extract the binary
tar xvf go1.12.linux-amd64.tar.gz

# Make root user the owner of Go workspace
sudo chown -R root:root ./go

# Move go directory to a standard location
sudo mv go /usr/local

For more details regarding Go installation check out

Golang Installation

For downloading Go binary for your platform checkout

Golang Downloads

To check if you installed Go successfully type:

# Displays installed Go version
go version

# Displays all environment variables defined by Go
go env

Docker:

docker run -it golang:1.11

Set $GOPATH variable

sudo nano ~/.profile

# Linux
export GOPATH=/usr/local/go
export GOBIN=$GOPATH/bin
export PATH=$PATH:/$GOBIN

# OSX
export GOPATH=$HOME/go
export GOBIN=$GOPATH/bin
export PATH=$PATH:/$GOBIN

# Save File

# Restart shell configuration
source ~/.profile

Other Go tools

You can also install other Go tools which will help you have a more productive development process

Go Tools

go get -u golang.org/x/tools/...

Go Lint

go get -u golang.org/x/lint/golint

Go Imports

go get -u golang.org/x/tools/cmd/goimports

Daily routine things

  • Format your entire code recursively using go fmt ./...

  • Lint your entire code recursively using golint ./...

For more info about Go check out

Go Doc

Go Packages

Go Playground

Effective Go

A Tour of Go

For more info about Go commands & WORKSPACE check out

Go commands explained

Go WORKSPACE explained

FEEDBACK โš—

GopherTuts TypeForm

COMMUNITY ๐Ÿ™Œ

GopherTuts Discord


Happy hacking gophers ๐Ÿš€๐Ÿš€๐Ÿš€

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.