Giter Club home page Giter Club logo

go-intro's Introduction

go-intro

Foray into Google's Go(lang)

Description

This package serves as a playground to get started with the Go language. Check out this cool article (sent to me by a friend) for the motivations behind Go

Syntax of the Go language

Variables in Go

There are 2 ways of doing this. Explicitly declaring the type of the variable or implicitly declaring a variable by assigning it a value and letting the compiler infer the type

var someVariable int
someVariable = 8
someVariable := 8

Printing in Go

import "fmt"

fmt.Println("This", "prints", "each", "word", "and adds a space automatically")
fmt.Print("All words are scrunched up with this print method.", "This word will come immediately after the full stop"

Running Go programmes

go run main.go
go build main.go

Functions in Go

func someFunction(someVariable int) int {
  fmt.Println("Going to return some integer")
  return someVariable
}

Pointers in Go

someVariable := 100
var somePointer *int
somePointer = &someVariable
fmt.Println("Printing out the variable pointed to by the pointer", *SomePointer)

Modifying scoped variables

func modifyVariable(var SomePointer *int) {
  *SomePointer += 1
}

*someVariablePtr := 8
modifyVariable(someVariablePtr)
fmt.Println("The new variable is:", someVariablePtr*)

if, else if and else conditionals

if (someCondition == true) {
  fmt.Println("The condition is true")
} else if (someCondition == false) {
  fmt.Println("The condition is false")
} else {
  fmt.Println("This a bug. Please report this.)
}

Switch statements in Go

switch someCondition {
case true: 
  fmt.Println("The condition is true")
case false:
  fmt.Println("The condition is false")
default:
  fmt.Println("This a bug. Please report this.)
}

go-intro's People

Contributors

denesh-globotix avatar developerdenesh avatar

Watchers

 avatar

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.