Menu
CoddyTech
Course

Go for C++ Developers

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

C++ and Go side by side

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

  1. Files and the first run

    C++ headers and translation units require declarations and linkage rules. Go files in one directory compile as a package and share package-level declarations without header includes. Imports are file-scoped. The deployed course uses one flat package main, not…

    C++
    1#include <iostream>2int main() { std::cout << "ready\n"; }
    Go
    1package main2import ("fmt")3
    4func main(){fmt.Println("Go", 3)}
  2. If and scoped names

    C++ offers a ternary expression; Go does not. Use explicit branches or a helper function to produce a selected result. Go switch normally exits the selected case without a break, unlike ordinary C++ fallthrough. Keep input validity checks ahead of threshold…

    C++
    1#include <algorithm>2#include <iomanip>3#include <iostream>4#include <map>5#include <numeric>6#include <stdexcept>7#include <string>8#include <utility>9#include <vector>10int main() {11    int score = 8;12    std::string result = score >= 10 ? "high" : score >= 5 ? "mid" : "low";13    std::cout << result << '\n';14}
    Go
    1package main2import ("fmt")3
    4func main(){if n := len("go"); n > 1 { fmt.Println("long") } else { fmt.Println("short") }}
  3. Arrays are values

    C++ vector assignment copies its elements into independent vector storage. Go array assignment copies the array, but slice assignment copies a descriptor referring to shared backing storage. A Go slice is not simply a vector with another spelling. Use make…

    C++
    1#include <algorithm>2#include <iomanip>3#include <iostream>4#include <map>5#include <numeric>6#include <stdexcept>7#include <string>8#include <utility>9#include <vector>10int main() {11    std::vector<int> items{4, 8};12    items.push_back(12);13    std::cout << items.back() << '\n';14}
    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

    C++ reference parameters can alias a caller object directly. Go always passes arguments by value, including pointer and slice values. A pointer receiver or parameter permits mutation through the copied pointer. Reassigning a local slice descriptor does not…

    C++
    1#include <algorithm>2#include <iomanip>3#include <iostream>4#include <map>5#include <numeric>6#include <stdexcept>7#include <string>8#include <utility>9#include <vector>10int main() {11    auto twice = [](int value) { return value * 2; };12    std::cout << twice(4) << '\n';13}
    Go
    1package main2import ("fmt")3func IsEven(n int) bool { return n%2==0 }4func main(){fmt.Println(IsEven(6))}
  5. Struct values

    C++ classes combine constructors, members and access specifiers. Go uses structs, receiver methods and ordinary factory functions. A factory name such as NewThing is a convention, not constructor syntax. Go has no automatic destructor invocation or base-class…

    C++
    1#include <algorithm>2#include <iomanip>3#include <iostream>4#include <map>5#include <numeric>6#include <stdexcept>7#include <string>8#include <utility>9#include <vector>10int main() {11    struct Parcel { std::string label; int weight; };12    Parcel parcel{"sample", 4};13    std::cout << parcel.label << '\n';14}
    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

    C++ exceptions unwind scopes and invoke destructors. Go ordinary errors are return values; callers decide whether to propagate or recover. A deferred cleanup is useful but does not turn error returns into exception handling. Panic is not the standard path for…

    C++
    1#include <algorithm>2#include <iomanip>3#include <iostream>4#include <map>5#include <numeric>6#include <stdexcept>7#include <string>8#include <utility>9#include <vector>10int main() {11    struct Guard {12        ~Guard() { std::cout << "released\n"; }13    };14    try {15        Guard guard;16        throw std::invalid_argument("bad");17    } catch (const std::invalid_argument&) {18        std::cout << "invalid\n";19    }20}
    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 C++ developers

Learn Go from another language

Frequently asked questions

Who is Go for C++ Developers for?

For people who already write C++ and want to learn Go. Each lesson starts from C++ 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 C++ basics: variables, conditions, loops, functions and collections.

How many lessons does Go for C++ Developers have?

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

What does Go for C++ Developers cover?

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

Is Go for C++ 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 C++ Developers for free

Get started