Video summary

Tutorial Golang Dasar (Bahasa Indonesia)

Main summary

Key takeaways

Educational

Main Ideas / Lessons Conveyed

1) Introductions & learning plan

  • The speaker (Eko Kurniawan) introduces the video/class as the first topic in a Go (Golang) learning roadmap.
  • Before starting Go, learners should be comfortable with:
    • Basic computer operation
    • Installing applications on Windows/macOS/Linux
    • Using the Terminal / Command Prompt, since Go code will be compiled and run from there

2) What Go/Golang is and why learn it

  • Go (often called “Golang”) was created by Google
  • Released publicly around 2009 as an open-source project
  • Gained popularity partly due to cloud/container technologies like Docker (around 2011)
  • Common use cases include:
    • Backend APIs, especially for microservices
  • Key reasons highlighted:
    • Relatively simple to learn
    • Built-in concurrency support (useful for multi-core systems)
    • A garbage collector, reducing manual memory management

3) Go toolchain basics

  • Go source files use the .go extension
  • The compiler compiles code into a binary/executable
  • Go supports compiling for multiple operating systems (e.g., Windows/macOS/Linux)

4) Installation & setup

  • Download and install Go compiler from golang.org, matching your OS
  • Verify installation with:
    • go version
  • Recommended editors:
    • Visual Studio Code (free)
    • JetBrains GoLand (paid; sometimes available via school/campus email)

5) Creating a Go project/module

  • Create a module with:
    • go mod init <module-name>
  • Notes:
    • Module name should contain no spaces
    • Initialization typically creates a go.mod file

6) Hello World structure and running Go programs

  • A minimal Go program includes:
    • package main
    • func main() as the entry point
  • Semicolons:
    • In Go, semicolons are not mandatory at line ends
  • Example requires importing:
    • fmt (e.g., import "fmt")
  • Build/run commands:
    • Compile: go build
    • Run source directly: go run <file>.go
  • Emphasized concept: Go is case-sensitive
    • e.g., fmt.Println must match capitalization exactly

7) Program organization rule: only one main() per package/module

  • If multiple files in the same module/package define func main(), go build will fail due to duplicate main
  • Suggested learning workaround:
    • Run files individually with go run <single-file>.go until the project is structured as a proper multi-file module/package

8) Core data types

Numbers

  • Integers:
    • int, int8, int16, int32, int64
  • Unsigned:
    • uint8, uint16, uint32, uint64
  • Floating point:
    • float32, float64
  • Complex:
    • complex64, complex128 (noted as rarely used; math-heavy)

Aliases

  • byte is an alias for uint8
  • rune is an alias for int32 (implicitly mentioned via alias concept)

Booleans

  • Use bool with true / false
  • Boolean literals should not be put in quotes

Strings

  • Strings use double quotes: "...".
  • String indexing/slicing concepts:
    • len(string) gives character count
    • s[i] returns a byte (numeric value)

9) Variables, constants, and assignment rules

  • Variables:
    • Must have a consistent data type
    • Common forms:
      • Typed declaration: var name string = "..." (or var name string)
      • Type inference: name := "..."
    • You cannot “create again” with the same name in the same scope
    • Unused declared variables may produce errors
  • Constants:
    • Use const
    • Must be initialized immediately
    • Cannot be changed later

10) Type conversion

  • Numeric conversions use:
    • targetType(value) (e.g., int64(x), int16(x))
  • Converting smaller integer types may cause overflow
  • For characters:
    • String indexing returns a byte (number)
    • Convert back with string(byteValue)

11) Type alias / type declaration

  • Create an alias using:
    • type NewName = ExistingType
  • Example intent:
    • Semantic aliasing (e.g., an ID card number alias of string)

12) Operators

  • Arithmetic: +, -, *, /, %
  • Augmented assignment: +=, -=, *=, /=, %=
  • Unary increment/decrement: ++, --
  • Comparisons (return boolean):
    • ==, !=, >, <, >=, <=
  • Boolean logic:
    • AND: &&
    • OR: ||
    • NOT: !

13) Arrays, slices, and slice behavior

  • Arrays
    • Fixed size; cannot grow
    • Indexed starting at 0
    • Out-of-bounds access causes an error
  • Slices
    • Dynamic view over an underlying array (can grow with append)
    • Key properties:
      • length (elements in the slice)
      • capacity (underlying array space from the slice’s start)
    • Slicing syntax:
      • arr[low:high] (where high is exclusive)
      • arr[: ] forms for flexible start/end
    • append may allocate a new underlying array if capacity is exceeded
    • Slice element modifications affect the underlying array (because slices reference the same backing storage)

14) Maps

  • Maps store key-value pairs
  • Keys must be unique; order is not guaranteed
  • Reading a missing key:
    • Does not error automatically; you get the zero value of the value type
  • Operations discussed:
    • Create with make(map[keyType]valueType)
    • Access by key: m[key]
    • len(m) returns number of entries
    • Remove with delete(m, key)
    • Setting an existing key overwrites its value

15) Branching: if/else, else if, switch

  • if conditions must be boolean
  • else handles the false case
  • else if evaluates in order and stops at the first true branch
  • if can include a short statement:
    • if x := ...; condition { ... }
  • switch
    • Compare one expression against multiple case options
    • Includes default
    • Can also use a short statement before the expression

16) Loops: for, for-range, break/continue

  • Basic for:
    • for condition { ... }
  • Classic for with init/condition/post:
    • for init; condition; post { ... }
  • for range
    • Works over slices, arrays, and maps
    • Provides index/value (or key/value for maps)
    • Use _ to ignore unused parts
  • Loop control:
    • break stops the entire loop
    • continue skips to the next iteration (after post logic, if applicable)

17) Functions

  • Define:
    • func name(...) { ... }
  • main() is the program entry point
  • Call functions as:
    • name(args...)
  • Parameters:
    • Typed, and must match when calling
  • Return values:
    • Use return <value>
    • Can return multiple values:
      • Capture with a, b := fn()
      • Use _ to ignore unwanted returns
  • Named return values:
    • Return parameters can be named in the function signature
  • Variadic functions:
    • Use ... in the final parameter: func sum(nums ...int)
    • Call with multiple args directly, or pass a slice with slice...

18) First-class functions

  • Functions can be:
    • Assigned to variables
    • Passed as parameters
  • The function type “contract” must match (e.g., func(string) string or func(string) bool)

19) Anonymous functions

  • Define functions inline
  • Often used by assigning to a variable or passing directly as an argument
  • Example theme: passing a blacklist/filter function into registerUser

20) Recursion

  • Demonstrated using factorial
    • First with a loop approach
    • Then recursively with a base case (n == 1)

21) Closures

  • Anonymous functions that capture variables from the surrounding scope
  • Closures can modify external variables (e.g., a counter) even if not passed explicitly

22) defer, panic, recover

  • defer
    • Schedules a function to run when the surrounding function finishes
    • Runs even when errors occur—until the function ends
  • panic
    • Stops normal execution and triggers deferred calls
  • recover
    • Used within deferred context to regain control after a panic (the demo was cut off mid-explanation)

Methodologies / Step-by-Step Instructions Included

A) Preparation before learning Go

  • Be comfortable with:
    • Operating a computer
    • Installing apps on your OS (Windows/macOS/Linux)
    • Using Terminal / Command Prompt
  • Practice Terminal since Go will be compiled and run from it

B) Installing Go

  • Download Go compiler from golang.org
  • Install the installer matching your OS:
    • Windows: MSI
    • macOS: PKG
    • Linux: appropriate build
  • Follow official installation steps
  • Verify:
    • Run go version
    • If it prints the Go version, installation succeeded

C) Creating a Go module/project

  • In the desired project folder, run:
    • go mod init <module-name>
  • Rules:
    • Module name must contain no spaces
  • Confirm:
    • A go.mod file should be generated

D) Building and running a Go program

  • Compile with:
    • go build
  • Run the compiled binary:
    • macOS/Linux: ./<binary-name>
    • Windows: <binary-name>.exe (as applicable)
  • Faster iteration during development:
    • go run <file>.go

E) Running multiple Go files during learning

  • If multiple files in the same package/module each define func main(), go build fails
  • Training approach:
    • Run each file individually:
      • go run helloWorld.go
      • go run sample.go
  • In real projects later:
    • Ensure only one main() exists in the correct main package/module structure

F) Basic “Hello World” program structure

  • At the top:
    • package main
  • Entry function:
    • func main() { ... }
  • Printing:
    • Import fmt: import "fmt"
    • Print: fmt.Println("Hello World")
  • Reminder:
    • Be careful with capitalization/spelling (Go is case-sensitive)

G) Working with arrays/slices/maps (core usage patterns)

  • Arrays
    • Fixed size: [N]<type>
    • Index starts at 0
    • Out-of-bounds causes an error
  • Slices
    • Use []<type> and create via slicing or make
    • Use len(slice) and cap(slice)
    • Grow using append(slice, values...)
    • Exceeding capacity triggers allocation of a new backing array
  • Maps
    • Create: make(map[keyType]valueType)
    • Set: m[key] = value
    • Read: m[key] (missing keys return zero value)
    • Remove: delete(m, key)
    • Size: len(m)

H) Control flow patterns

  • if/else: condition must be boolean
  • switch: compare one expression to multiple case values; use default
  • for loops:
    • Use for init; condition; post or for condition
  • for range:
    • for i, v := range collection { ... }
    • Use _ to ignore unused parts
  • break/continue:
    • break ends loop
    • continue skips to next iteration

I) Function patterns

  • Basic:
    • func name(params...) returnType { ... }
  • Parameters:
    • Types must match at call sites
  • Returning values:
    • Use return
  • Multiple returns:
    • Capture with multiple variables
    • Use _ to ignore returned values
  • Variadic:
    • Define last param with ...
    • Call with multiple args or pass a slice with slice...

J) Function-as-value / function-as-parameter

  • Define function type contract (e.g., func(string) string)
  • Pass matching functions into parameters
  • Call the passed function inside the receiving function

K) Closure/defer/panic/recover conceptual steps

  • Closure:
    • Create an anonymous function capturing outer variables
  • defer:
    • Schedule a function to run at the end of the current function
  • panic:
    • Stop normal execution and trigger deferred calls
  • recover:
    • Used within deferred context to capture a panic and continue (demo incomplete)

Speakers / Sources Featured (as Stated in Subtitles)

  • Eko Kurniawan (speaker/teacher; technical architect and instructor)
  • Go (Golang) / Google (Go created by Google)
  • golang.org (official website to download/install Go)
  • Mentioned examples of tech usage: Google, Docker, Kubernetes, Prometheus, CrossDB/other DBs
  • Editors/tools:
    • Visual Studio Code
    • JetBrains GoLand

Rate this summary

Your feedback will help improve summaries.

Improve this summary

Reprocess with a stronger model when the summary feels incomplete or inaccurate.

Pro

Translate summary in another language

Pro

Ask questions to this video

Chat for follow-up questions, clarifications, and source-backed answers.

Coming soon

Share this summary

Original video