Menu
CoddyTech
Course

Go for Kotlin Developers

Transfer your Kotlin experience to Go: typed values, control flow, arrays, slices, functions, methods, interfaces and error handling. Build a tested multi-file order pipeline.

Kotlin and Go side by side

The same program in Kotlin and in Go, from the lessons of this course.

  1. Files and the first run

    Kotlin supports top-level functions, so a small console application does not need a wrapper class. Go similarly starts at main, but executable files declare package main. Go package declarations group files in one directory, while each file declares its own…

    Kotlin
    1
    2fun main() {3println("Kotlin")4}
    Go
    1package main2import ("fmt")3
    4func main(){fmt.Println("Go", 3)}
  2. If and scoped names

    Kotlin if is an expression, and flow analysis can smart-cast a suitable value after a type or null check. Go if is a statement and may include an initializer scoped through its else branches. Move declarations carefully: a Kotlin local declared before if…

    Kotlin
    1
    2fun main() {3val n="go".length; if(n>1) println("long") else println("short")4}
    Go
    1package main2import ("fmt")3
    4func main(){if n := len("go"); n > 1 { fmt.Println("long") } else { fmt.Println("short") }}
  3. Arrays are values

    A Kotlin IntArray is a reference to mutable fixed-length storage; assigning it aliases the same array. Go [2]int is a value whose length belongs to its type and whose elements copy on assignment. Kotlin copyOf explicitly separates the storage in this scalar…

    Kotlin
    1
    2fun main() {3val a=intArrayOf(3,5); val b=a.copyOf(); b[0]=9; println(listOf(a[0],b[0]).joinToString(" "))4}
    Go
    1package main2import ("fmt")3
    4func main(){a:=[2]int{3,5}5b:=a6b[0]=97fmt.Println(a[0],b[0])}
  4. Typed function contracts

    Kotlin functions support defaults, named arguments and overloading. Go functions have one declared signature per name and no default arguments. Both pass values; a copied Kotlin object reference or Go slice descriptor can still reach shared state. Specify…

    Kotlin
    1fun isEven(n:Int):Boolean = n%2==02fun main() {3println(isEven(6))4}
    Go
    1package main2import ("fmt")3func IsEven(n int) bool { return n%2==0 }4func main(){fmt.Println(IsEven(6))}
  5. Struct values

    Kotlin class instances, including data classes, have reference semantics. A data-class copy explicitly constructs another instance and is shallow. Go structs copy on assignment, but reference-like fields can still share storage. The scalar text field here…

    Kotlin
    1data class Label(var text:String)2fun main() {3val a=Label("old"); val b=a.copy(); b.text="new"; println(a.text+" "+b.text)4}
    Go
    1package main2import ("fmt")3type Label struct { Text string }4func main(){a:=Label{Text:"old"}5b:=a6b.Text="new"7fmt.Println(a.Text,b.Text)}
  6. Errors are returned values

    Kotlin exceptions are unchecked and can be handled with try/catch expressions. Go APIs normally return an error result that callers must inspect. Translate expected rejection into the returned-error contract instead of using panic for every invalid request.…

    Kotlin
    1fun positive(n:Int):Int { require(n>0) { "not positive" }; return n }2fun main() {3try { positive(-2) } catch(e:IllegalArgumentException) { println("rejected") }4}
    Go
    1package main2import ("fmt";"errors")3func Positive(n int)(int,error) { if n<=0{return 0,errors.New("not positive")};return n,nil }4func main(){_,e:=Positive(-2)5fmt.Println(e!=nil)}

Syllabus

9 chapters48 lessons1 project48 challenges99 quiz questions

More courses for Kotlin developers

Learn Go from another language

Frequently asked questions

Who is Go for Kotlin Developers for?

For people who already write Kotlin and want to learn Go. Each lesson starts from Kotlin you know and shows how Go does the same thing, so you skip the beginner basics.

Do I need to know Go already?

No. The course starts with your first Go program. You need Kotlin basics: variables, conditions, loops, functions and collections.

How many lessons does Go for Kotlin Developers have?

Go for Kotlin Developers contains 48 interactive lessons you can complete at your own pace.

What does Go for Kotlin Developers cover?

The course is organized into chapters covering: Values and expressions, Control flow, Collections, Functions and pointers, and more.

Is Go for Kotlin Developers free?

Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.

Coddy programming languages illustration

Start Go for Kotlin Developers for free

Get started