Go for Lua Developers
Transfer your Lua experience to Go: typed values, control flow, arrays, slices, functions, methods, interfaces and error handling. Build a tested multi-file order pipeline.
Lua and Go side by side
The same program in Lua and in Go, from the lessons of this course.
Files and the first run
Lua executes a chunk through its host interpreter; a console script can run statements directly. Go builds a program from package main and calls main as its entry function. Package-level Go declarations can be shared across files in the directory, while…
Lua1print("Lua 5.4")Go1package main2import ("fmt")3 4func main(){fmt.Println("Go", 3)}If and scoped names
Lua locals are block-scoped; a declaration inside then is unavailable to a separate else block. Go can place an initializer before an if condition and keep it in scope through all branches. Choose the smallest useful scope when porting, rather than…
Lua1local n=#"go"; if n>1 then print("long") else print("short") endGo1package main2import ("fmt")3 4func main(){if n := len("go"); n > 1 { fmt.Println("long") } else { fmt.Println("short") }}Arrays are values
Lua tables are shared objects: assignment does not copy their entries. Go fixed arrays are values with a length in their type, and assignment copies elements. Explicitly copying a Lua sequence models independent scalar slots; nested table values would still…
Lua1local a={3,5}; local b={}; for i,v in ipairs(a) do b[i]=v end; b[1]=9; print(a[1].." "..b[1])Go1package main2import ("fmt")3 4func main(){a:=[2]int{3,5}5b:=a6b[0]=97fmt.Println(a[0],b[0])}Typed function contracts
Lua functions accept dynamically typed arguments, fill missing fixed parameters with nil and ignore extra arguments unless captured variadically. Go checks a declared signature and has no default arguments. Copied references can still share storage in either…
Lua1local function is_even(n) return n%2==0 end; print(is_even(6))Go1package main2import ("fmt")3func IsEven(n int) bool { return n%2==0 }4func main(){fmt.Println(IsEven(6))}Struct values
Lua table assignment shares identity, whereas Go struct assignment copies named fields. A new Lua table can model separate scalar fields, but nested tables remain shared when copied by reference. Go structs likewise may retain shared storage through pointer…
Lua1local a={text="old"}; local b={text=a.text}; b.text="new"; print(a.text.." "..b.text)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
Lua error interrupts execution and pcall returns a success flag plus results or an error value. Go APIs normally return errors directly without using panic for routine rejection. Distinguish a protected call from an ordinary value/error convention and…
Lua1local function positive(n) if n<=0 then error("not positive") end; return n end; local ok=pcall(positive,-2); if not ok then print("rejected") endGo1package 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 Lua Developers for?
For people who already write Lua and want to learn Go. Each lesson starts from Lua 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 Lua basics: variables, conditions, loops, functions and collections.
How many lessons does Go for Lua Developers have?
Go for Lua Developers contains 48 interactive lessons you can complete at your own pace.
What does Go for Lua Developers cover?
The course is organized into chapters covering: Values and expressions, Control flow, Collections, Functions and pointers, and more.
Is Go for Lua Developers free?
Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.