Kotlin for Go Developers
Transfer Go experience to Kotlin through null safety, collections, functions, properties and object contracts. Build a connected multi-file order processor and port a stock ledger.
Go and Kotlin side by side
The same program in Go and in Kotlin, from the lessons of this course.
Strings and Templates
Kotlin, like Go, permits top-level functions, and this standalone file starts in main without a class. It needs no package main clause and no import for printing, because println is built in. Go has no string interpolation: fmt.Println joins its operands with…
Go1package main2 3import "fmt"4 5func main() {6 ready := 37 fmt.Println("Ready:", ready)8}Kotlin1fun main(){2val ready=33println("Ready: $ready")4}Equality and Identity
Kotlin == invokes null-safe structural equality through equals; === tests reference identity. Go == on pointers compares addresses, which corresponds to the latter, while Go == on struct values compares every field. Kotlin does not invent field equality for…
Go1package main2 3import "fmt"4 5type Point struct{ X, Y int }6 7func main() {8 p := Point{1, 2}9 q := Point{1, 2}10 fmt.Println(p == q, &p == &q)11}Kotlin1data class Point(val x:Int, val y:Int)2 3fun main(){4val p=Point(1,2)5val q=Point(1,2)6println("${p==q} ${p===q}")7}Arrays and IntArray
Kotlin IntArray stores primitive ints with a size fixed at creation, much like a Go array, while Array<Int> boxes each element. Unlike a Go array, which is a value copied on assignment and when passed to a function, an IntArray is a reference: assigning it…
Go1package main2 3import "fmt"4 5func main() {6 a := [...]int{4, 8, 12}7 fmt.Println(a[len(a)-1])8}Kotlin1fun main(){2val a=intArrayOf(4,8,12)3println(a.last())4}While, Break, and Continue
Kotlin while repeats while a Boolean condition holds, the job Go gives to a condition-only for. break exits the nearest loop, continue skips the current iteration, and both languages have labels for deliberate outer-loop jumps. One rule differs: a bare break…
Go1package main2 3import (4 "fmt"5 "strings"6)7 8func main() {9 kept := []string{}10 for _, word := range []string{"tea", "", "STOP", "coffee"} {11 if word == "STOP" {12 break13 }14 if word == "" {15 continue16 }17 kept = append(kept, word)18 }19 fmt.Println(strings.Join(kept, ","))20}Kotlin1fun main(){2val kept=mutableListOf<String>()3for(word in listOf("tea","","STOP","coffee")){if(word=="STOP")break;if(word.isEmpty())continue;kept.add(word)}4println(kept.joinToString(","))5}Top-level Functions
As in Go, a Kotlin top-level function needs no wrapper type, and files of one package call each other's functions without imports. Kotlin declarations are public by default and narrowed with private or internal, never by the case of the first letter.…
Go1package main2 3import "fmt"4 5func isLong(s string) bool {6 return len(s) > 47}8 9func main() {10 fmt.Println(isLong("coffee"))11}Kotlin1fun isLong(text:String):Boolean = text.length>42fun main(){3println(isLong("coffee"))4}Input and String Formatting
Kotlin readlnOrNull returns null at end of input, as a Go bufio.Scanner returns false from Scan; the locked driver uses it to collect lines. toInt, like strconv.Atoi, requires complete numeric text, so trim only when surrounding whitespace is allowed. Go fmt…
Go1package main2 3import (4 "fmt"5 "strings"6)7 8func main() {9 fmt.Println(strings.ToUpper(strings.TrimSpace(" tea ")))10}Kotlin1fun main(){2println(" tea ".trim().uppercase())3}
Syllabus
10 chapters48 lessons1 project48 challenges99 quiz questionsStarting Kotlin
6 lessonsValues and Decisions
5 lessonsCollections and Ownership
5 lessonsIteration and Transformations
5 lessonsFunctions and Callbacks
5 lessonsInput, Errors, and Files
5 lessonsClasses and State
6 lessonsComposition and Value Types
5 lessonsProject: Order Processing
4 lessonsFinal Challenges
2 lessonsFrequently asked questions
Who is Kotlin for Go Developers for?
For people who already write Go and want to learn Kotlin. Each lesson starts from Go you know and shows how Kotlin does the same thing, so you skip the beginner basics.
Do I need to know Kotlin already?
No. The course starts with your first Kotlin program. You need Go basics: variables, conditions, loops, functions and collections.
How many lessons does Kotlin for Go Developers have?
Kotlin for Go Developers contains 48 interactive lessons you can complete at your own pace.
What does Kotlin for Go Developers cover?
The course is organized into chapters covering: Starting Kotlin, Values and Decisions, Collections and Ownership, Iteration and Transformations, and more.
Is Kotlin for Go Developers free?
Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.