Claude is down today. ๐
Seems Claude was used to write the code, help with the deployment, and now to debug the problem.
But Claude is down.
So basically, Karthik is calling Karthik. ๐คฃ
At this point, even Claude needs a developer.
This is part of my Go course on YouTube, from basics to advanced topics.
๐บ Channel: https://t.co/ytWo1NbODB
๐ Full playlist: [playlist link]
Questions? Drop them here or under the video.
New video: Functions in Go ๐น
Covers:
โ Multiple return values
โ Blank identifier (_)
โ Named returns and the explicit-return catch
โ Variadic functions
Plus the compiler errors you'll actually hit, and how to fix them.
https://t.co/GJvI7pxUtK
#golang#go
func add(a, b int) (c int) {
c = a + b
return 50
}
This returns 50, not a + b. An explicit return value is assigned to c first, overwriting it. Explained in the video.
Quick quiz ๐ง Which of these compile? (divide returns two ints)
A) q := divide(17, 5)
B) q, _ := divide(17, 5)
C) _, _ := divide(17, 5)
Reply with your answer before running it ๐
fmt.Println(0.1 + 0.2) // 0.3
a, b := 0.1, 0.2
fmt.Println(a + b) // 0.30000000000000004
Constants are computed at compile time with arbitrary precision, then converted.
Variables are two imprecise float64s added at runtime.
Go is statically typed AND it infers types.
Beginners hear that and assume it works like Python. It doesn't:
a := 10
a = 10.5 // won't compile
Inference picks the type once, at compile time. Then it's locked in.
https://t.co/wn1uywL8eY
What's covered:
- var, grouped var blocks, and :=
- zero values, and why Go has no uninitialized variables
- why 10, 10.0 and 'a' infer to three different types
- the "declared and not used" compile error
- why := doesn't work at package level
Context: I wrote Hands-On Go Programming and have been building Go backends for over a decade.
This is part of a full Go course I'm publishing. Modules, packages and testing are next.
https://t.co/TkaLlE9DQx
Most Go tutorials open with Hello World.
This one opens with go mod init โ because the module is what everything else hangs off.
New video: your first Go program, set up properly from line one.
https://t.co/ZdjOW6qnQN
#golang#programming#coding#tutorial
Also in the video: main.go is a convention, not a rule.
Rename it to hello_world.go, run go run . again, identical output.
Go cares about the package and the signature of func main. The file name is yours.
Small thing people trip on:
go build main.go โ binary called main
go build . โ binary named after the last element of your module path
Want your own name: go build -o my_run .
#shorthands and bool flags deep dive in #pflag in #golang. It covers:
- Introduction
-Shorthand
-Rules
-Single Dash with Multiple Bool Flags
- Different Ways to Pass Bool Values
- BoolFunc and BoolFuncP
https://t.co/XD8w5xHTn6
#code