Video summary
Tutorial Golang Dasar (Bahasa Indonesia)
Main summary
Key takeaways
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
.goextension - 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.modfile
6) Hello World structure and running Go programs
- A minimal Go program includes:
package mainfunc 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
- Compile:
- Emphasized concept: Go is case-sensitive
- e.g.,
fmt.Printlnmust match capitalization exactly
- e.g.,
7) Program organization rule: only one main() per package/module
- If multiple files in the same module/package define
func main(),go buildwill fail due to duplicate main - Suggested learning workaround:
- Run files individually with
go run <single-file>.gountil the project is structured as a proper multi-file module/package
- Run files individually with
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
byteis an alias foruint8runeis an alias forint32(implicitly mentioned via alias concept)
Booleans
- Use
boolwithtrue/false - Boolean literals should not be put in quotes
Strings
- Strings use double quotes:
"...". - String indexing/slicing concepts:
len(string)gives character counts[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 = "..."(orvar name string) - Type inference:
name := "..."
- Typed declaration:
- 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
- Use
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)
- Semantic aliasing (e.g., an ID card number alias of
12) Operators
- Arithmetic:
+,-,*,/,% - Augmented assignment:
+=,-=,*=,/=,%= - Unary increment/decrement:
++,-- - Comparisons (return boolean):
==,!=,>,<,>=,<=
- Boolean logic:
- AND:
&& - OR:
|| - NOT:
!
- AND:
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](wherehighis exclusive)arr[: ]forms for flexible start/end
appendmay allocate a new underlying array if capacity is exceeded- Slice element modifications affect the underlying array (because slices reference the same backing storage)
- Dynamic view over an underlying array (can grow with
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
- Create with
15) Branching: if/else, else if, switch
ifconditions must be booleanelsehandles the false caseelse ifevaluates in order and stops at the first true branchifcan include a short statement:if x := ...; condition { ... }
switch- Compare one expression against multiple
caseoptions - Includes
default - Can also use a short statement before the expression
- Compare one expression against multiple
16) Loops: for, for-range, break/continue
- Basic
for:for condition { ... }
- Classic
forwith 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:
breakstops the entire loopcontinueskips 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
- Capture with
- Use
- 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...
- Use
18) First-class functions
- Functions can be:
- Assigned to variables
- Passed as parameters
- The function type “contract” must match (e.g.,
func(string) stringorfunc(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
- Run
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.modfile should be generated
- A
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)
- macOS/Linux:
- 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 buildfails - Training approach:
- Run each file individually:
go run helloWorld.gogo run sample.go
- Run each file individually:
- In real projects later:
- Ensure only one
main()exists in the correctmainpackage/module structure
- Ensure only one
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")
- Import
- 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
- Fixed size:
- Slices
- Use
[]<type>and create via slicing ormake - Use
len(slice)andcap(slice) - Grow using
append(slice, values...) - Exceeding capacity triggers allocation of a new backing array
- Use
- 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)
- Create:
H) Control flow patterns
if/else: condition must be booleanswitch: compare one expression to multiplecasevalues; usedefaultforloops:- Use
for init; condition; postorfor condition
- Use
for range:for i, v := range collection { ... }- Use
_to ignore unused parts
break/continue:breakends loopcontinueskips to next iteration
I) Function patterns
- Basic:
func name(params...) returnType { ... }
- Parameters:
- Types must match at call sites
- Returning values:
- Use
return
- Use
- 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...
- Define last param with
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.
Translate summary in another language
Ask questions to this video
Chat for follow-up questions, clarifications, and source-backed answers.