Go for Rust Developers
Transfer your Rust experience to Go: typed values, control flow, slices, functions, methods, interfaces and error handling. Build a tested multi-file order pipeline.
Rust and Go side by side
The same program in Rust and in Go, from the lessons of this course.
Files and the first run
Rust mod declarations, crates and use paths are not Go file includes. Go files in one directory declare a common package and compile together; imports belong to individual files. Exported Go names begin uppercase. The runner uses a flat package main with no…
Rust1fn main() { println!("ready"); }Go1package main2import ("fmt")3 4func main(){fmt.Println("Go", 3)}If and scoped names
Rust if and match can produce values, and matching enum variants exposes associated data. Go if and switch are statements. Assign in each branch or return explicitly. A Go named integer type with constants does not prevent unnamed numeric values the way a…
Rust1fn main() {2let score = 8;3let result = if score >= 10 { "high" }4 else if score >= 5 { "mid" } else { "low" };5println!("{}", result);6}Go1package main2import ("fmt")3 4func main(){if n := len("go"); n > 1 { fmt.Println("long") } else { fmt.Println("short") }}Arrays are values
Rust Vec owns its allocation and borrowing rules control access to slices. A Go slice is a descriptor for shared backing storage managed by garbage collection. Copying it does not transfer ownership or prevent aliases. A Go array is instead a value whose…
Rust1fn main() {2let mut items = vec![4, 8];3items.push(12);4println!("{}", items[items.len() - 1]);5println!("{:?}", &items[..2]);6}Go1package main2import ("fmt")3 4func main(){a:=[2]int{3,5}5b:=a6b[0]=97fmt.Println(a[0],b[0])}Typed function contracts
Rust function parameters can move ownership or borrow through references. Go parameters are always passed by value, including pointer and slice descriptors. A Go pointer permits mutation without a compile-time unique-borrow guarantee. Return explicitly; Go…
Rust1fn main() {2fn twice(value: i32) -> i32 { value * 2 }3println!("{}", twice(4));4}Go1package main2import ("fmt")3func IsEven(n int) bool { return n%2==0 }4func main(){fmt.Println(IsEven(6))}Struct values
Rust structs hold data and impl blocks add associated functions and methods. Go structs and receiver methods play similar roles, but there are no inherent impl blocks or Self type shorthand. A New-style Go factory is an ordinary function. Neither language…
Rust1fn main() {2struct Parcel { label: String, weight: i32 }3let parcel = Parcel { label: String::from("sample"), weight: 4 };4println!("{}", parcel.label);5assert_eq!(parcel.weight, 4);6}Go1package main2import ("fmt")3type Label struct { Text string }4func main(){a:=Label{Text:"old"}5b:=a6b.Text="new"7fmt.Println(a.Text,b.Text)}Errors are returned values
Rust Result and the ? operator propagate typed success/failure structure. Go conventionally returns a value and error, with explicit if err != nil handling. Panic is not a routine replacement for Err. Preserve the original failure information when adding…
Rust1fn main() {2struct Guard;3impl Drop for Guard { fn drop(&mut self) { println!("released"); } }4let result = {5 let _guard = Guard;6 "bad".parse::<i32>()7};8if result.is_err() { println!("invalid"); }9}Go1package 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 questionsValues and expressions
7 lessonsControl flow
5 lessonsCollections
6 lessonsFunctions and pointers
6 lessonsTypes and behavior
8 lessonsErrors and organization
6 lessonsText and absence
4 lessonsOrder pipeline
Project4 lessonsFinal challenges
2 lessonsFrequently asked questions
Who is Go for Rust Developers for?
For people who already write Rust and want to learn Go. Each lesson starts from Rust 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 Rust basics: variables, conditions, loops, functions and collections.
How many lessons does Go for Rust Developers have?
Go for Rust Developers contains 48 interactive lessons you can complete at your own pace.
What does Go for Rust Developers cover?
The course is organized into chapters covering: Values and expressions, Control flow, Collections, Functions and pointers, and more.
Is Go for Rust Developers free?
Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.