Menu
CoddyTech
Course

Swift for Go Developers

Move from Go structs, slices, interfaces and error returns to Swift values, optionals, protocols and ARC. Practice with 48 multi-file tasks, build a parcel desk and port two complete Go applications.

Go and Swift side by side

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

  1. Bindings and Mutation

    Go const declares a compile-time constant, while a Swift let binding may receive a runtime value and then cannot be reassigned. Go := infers a local variable type without making it immutable. Swift chooses inference separately from let or var mutability.

    Go
    1package main2import (3    "fmt"4)5
    6func main() {7const saved = 188    current := saved9    current = 2110    fmt.Println(saved, current)11}
    Swift
    1import Foundation2let saved = 183var current = saved4current = 215print("\(saved) \(current)")
  2. Strings and Interpolation

    Go fmt formatting inserts values through format verbs, while Swift String interpolation uses a backslash and parentheses. The literal percent sign is escaped as %% in the source format string. Text construction and printing can be separated with a returned…

    Go
    1package main2import (3    "fmt"4)5
    6func main() {7percent := 408    fmt.Printf("Downloaded %d%%\n", percent)9}
    Swift
    1import Foundation2let percent = 403print("Downloaded \(percent)%")
  3. Switch and Patterns

    Go and Swift switches do not implicitly fall through to the next body. Both support multiple alternatives sharing a case. Go permits switches without explicit exhaustive coverage, while Swift requires every possible value to be covered or an appropriate…

    Go
    1package main2import (3    "fmt"4)5
    6func main() {7command := "?"8    switch command {9    case "help", "?": fmt.Println("show help")10    case "quit": fmt.Println("close")11    default: fmt.Println("unknown")12    }13}
    Swift
    1import Foundation2let command = "?"3switch command {4case "help", "?": print("show help")5case "quit": print("close")6default: print("unknown")7}
  4. Functions and Labels

    Go and Swift support free functions, but Go ordinary calls use positional arguments and do not provide language-level default parameters. Swift separates an external argument label from the local parameter name and can supply a default value.

    Go
    1package main2import (3    "fmt"4    "strings"5)6func line(symbol string, count int) string { return strings.Repeat(symbol, count) }7
    8func main() {9fmt.Println(line("*", 3))10}
    Swift
    1import Foundation2func line(_ symbol: String, count: Int = 3) -> String {3    String(repeating: symbol, count: count)4}
  5. Dictionaries and Missing Keys

    Go map lookup returns the element zero value for a missing key, with the optional comma-ok result distinguishing absence from a stored zero. Swift Dictionary packages that distinction into an Optional result. A fallback should be used deliberately rather than…

    Go
    1package main2import (3    "fmt"4)5
    6func main() {7settings := map[string]int{"zoom": 2}8    settings["zoom"] = 39    zoom, ok := settings["zoom"]10    if !ok { zoom = 1 }11    speed, ok := settings["speed"]12    if !ok { speed = 1 }13    fmt.Println(zoom, speed)14}
    Swift
    1import Foundation2var settings = ["zoom": 2]3settings["zoom"] = 34print("\(settings["zoom"] ?? 1) \(settings["speed"] ?? 1)")
  6. Structs and Independent Copies

    Go struct assignment copies its field values, while assigning a pointer shares the pointed-to struct. Swift structs similarly preserve value semantics, but methods that modify their stored properties explicitly use mutating. Go commonly uses a pointer…

    Go
    1package main2type Theme struct { Name string }3func (theme *Theme) Select(value string) { theme.Name = value }
    Swift
    1import Foundation2struct Theme {3    var name: String4    mutating func select(_ value: String) { name = value }5}

Syllabus

10 chapters48 lessons1 project48 challenges99 quiz questions

More courses for Go developers

Learn Swift from another language

Frequently asked questions

Who is Swift for Go Developers for?

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

Do I need to know Swift already?

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

How many lessons does Swift for Go Developers have?

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

What does Swift for Go Developers cover?

The course is organized into chapters covering: Starting Swift, Text and Decisions, Control Flow, Functions and Arrays, and more.

Is Swift 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.

Coddy programming languages illustration

Start Swift for Go Developers for free

Get started