Section 1

Preview this deck

How do you declare a variable without saying "var"?

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

7 years ago

Date created

Mar 1, 2020

Cards (30)

Section 1

(30 cards)

How do you declare a variable without saying "var"?

Front

:= Ex: name := "Samm"

Back

How do you print out the value of a key from a map?

Front

fmt.Println(mapName["mapKey"])

Back

How do you define a function?

Front

func funcName() { // statements } Ex: func main() { }

Back

Who created Go?

Front

Robert Griesemer, Rob Pike, and Ken Thompson.

Back

All Go programs start with a package declaration. How do you do this?

Front

package main

Back

How do you print text to the screen?

Front

fmt.Println("Text to the screen")

Back

How do you declare a variable?

Front

var varName = value Ex: var myAge = 17.5

Back

How do you make a for loop?

Front

for i := 1; i <= 10; i++ { fmt.Println(i) } i := 1 declares the variable i to the value of 1 i <= 10 tells the loop to run while i is less than or equal to ten i++ increments the variable i by one each iteration

Back

How do you make a slice?

Front

sliceName = [] int {1, 2, 3, 4, 5}

Back

Are semicolons needed in Go?

Front

No, they are not.

Back

Where was Go created?

Front

Google.

Back

How do you do string interpolation?

Front

fmt.Println("Hi my name is", "Samm")

Back

How do you make a single lined comment?

Front

//

Back

How do you make an if statement in Go?

Front

if age = 16 { fmt.Println("Go drive") }

Back

How do you do variable interpolation?

Front

fmt.Println("I am Samm and I am", age, "what about you?")

Back

What is a slice?

Front

Like an array, but NOT fixed length sequence of items.

Back

How do you make an if else statement in Go?

Front

if age = 16 { fmt.Println("Go drive") } else { fmt.Println("Have fun") }

Back

How do you make an if, else if, else statement in Go?

Front

if age = 16 { fmt.Println("Drive") } else if age = 18 { fmt.Println("Vote") } else { fmt.Println("Drink") }

Back

How do you make a switch statement in Go?

Front

age := 16 switch age { case 16 : fmt.Println("Drive") case 18 : fmt.Println("Vote") case 21 : fmt.Println("Drink") default: fmt.Println("Have fun") }

Back

How do you import things into your program?

Front

import " " Ex: import "fmt"

Back

How do you get the length of a map?

Front

fmt.Println(len(mapName))

Back

Create a Hello World program...

Front

package main import "fmt" func main() { fmt.Println("Hello, World!") }

Back

How do you define a constant?

Front

const varName dataType = value Ex: const pi float64 = 3.14159265 You MUST define the variable's data type with constants.

Back

How do you make an array?

Front

arrayName := [arrayNumbers] float64 {1, 2, 3, 4, 5} Example if you have five values in your array: arrayName := [5] float64 {1, 2, 3, 4, 5}

Back

How do you delete a key from a map?

Front

delete(mapName, "mapKey")

Back

How do you make a map and add values into it?

Front

nameAge := make(map[string] int) nameAge ["Samm"] = 18 [string] defines the type that the keys are going to be int defines the type the values are going to be

Back

What is a map?

Front

A collection of key/value pairs.

Back

How do you make a multi lined comment?

Front

/ multi line comment /

Back

When was Go created?

Front

2007

Back

What is an array?

Front

A fixed length sequence of items.

Back