Golang Code

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/17

flashcard set

Earn XP

Description and Tags

Common declarations and formatting of code in Go

Last updated 11:33 PM on 8/10/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

18 Terms

1
New cards

variable declaration without a corresponding initialization

var x int

2
New cards

variable declaration shorthand syntax within golang functions

:=

3
New cards

variable declaration with declared type

var a string = "initial"

4
New cards

for-loop w/ single condition

for i <= 3 { 
	fmt.Println(i)
	i = i + 1
}

5
New cards

classic for-loop

for j:= 0; j < 3; j++ {
	fmt.Println(j)
}

6
New cards

for-loop w/ range

for i := range 3 {
	fmt.Println("range", i)
}

7
New cards

for-loop w/out condition

for {
	fmt.Println("loop")
	break
}

8
New cards

basic if/else

if a = true {
    fmt.Println("True")
else {
    fmt.Println("False")
}

9
New cards

basic switch statement


switch i {
    case 1:
        fmt.Println("one")
    case 2:
        fmt.Println("two")
    case 3:
	fmt.Println("three")

10
New cards

array declaration of size 5

var a [5]int

11
New cards

array declaration of size 5 with initialization of 5 ints

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

12
New cards

Array Declaration w/ initializations and complier determined size

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

13
New cards

2D Array declaration

twoD := [2][3]int{
	{1, 2, 3}, 
	{1, 2, 3},
}

14
New cards

basic slice declaration of type string

var s []string

15
New cards

Slice Declaration w/ non-zero length and capacity

s = make([]string, length, capacity)

16
New cards

Copy a Slice

var s  = []string{"a", "b", "c"}
c := make([]string, len(s))
copy(c, s)

17
New cards

2D Slice

twoD := [][]int{
	{1, 2, 3}, 
	{4, 5, 6},
}

18
New cards