Skip to content

gstelang/go-by-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

go-by-example

Basics

Set GOPATH
go version
go help
godoc fmt println
go run main.go

Concepts

  • package main
  • imports
import "fmt"
fmt.Println("Hello, World")

  • Data types - Integers, floating point numbers, strings, Boolean
fmt.Println("1 + 1 = ", 1 + 1) 
fmt.Println("1.0 + 1.0 = ", 1.0 + 1.0)
len("Hello, World")
fmt.Println((true && true)

  • Variables
var x string = "Hello"
x := "Hello" // type inference
y := 5.  // type inference
Scope (Declare outside)
const x string = "Hello" // constants
// Multiple variables
var (
  a = 5
  b = 10
)
fmt.println(`
1
2
3
`)

About

Learning go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors