🐹 Introduction to Go LESSON 🔢 Basic Types LESSON 📦 Variables WORKSHOP 🧪 Variables Lab LAB 📍 Pointers LESSON 📍 Pointers Workshop WORKSHOP ⚙️ Functions LESSON 🔨 Functions Workshop WORKSHOP 🔒 Closures LESSON 🔒 Closures Workshop WORKSHOP 🌡️ Temperature Converter Lab LAB 🔀 Control Flow LESSON 🔀 Control Flow Workshop WORKSHOP 📦 Arrays LESSON 🍕 Slices WORKSHOP 🔗 Functional Pipeline Lab LAB 🗺️ Maps WORKSHOP 📊 Word Frequency Analyzer Lab LAB 🏗️ Structs LESSON 🏦 Structs Workshop WORKSHOP ✅ Task Manager Lab LAB 🔌 Interfaces LESSON 🔌 Interfaces Workshop WORKSHOP 📐 Shapes Calculator Lab LAB 📖 io.Reader LESSON ⚠️ Error Handling LESSON 🔧 Error Handling Workshop WORKSHOP 🛡️ Input Validator Lab LAB 🛟 Defer, Panic, and Recover LESSON 🛟 Defer, Panic & Recover Workshop WORKSHOP 📝 Strings & Runes LESSON 📝 Strings & Runes Workshop WORKSHOP 📋 JSON Encoding LESSON 🔨 JSON Workshop WORKSHOP 🗃️ Product Catalog Lab LAB ⚡ Goroutines & Channels LESSON ⚡ Goroutines Workshop WORKSHOP 🧬 Generics LESSON 🧬 Generics Workshop WORKSHOP 🌐 HTTP Basics LESSON 🔨 HTTP Workshop WORKSHOP 🛒 Item Store API Lab LAB 🧪 Testing in Go LESSON 🧪 Testing Workshop WORKSHOP 🧮 Calculator Test Lab LAB 🔗 context.Context LESSON 🔗 Context Workshop WORKSHOP 📂 File I/O LESSON 📂 File I/O Workshop WORKSHOP 📄 Word Count Lab LAB ⏱️ time & sync extras LESSON ⏱️ time & sync Workshop WORKSHOP 🔀 Concurrency Patterns LESSON 🔀 Concurrency Patterns Workshop WORKSHOP 📋 Structured Logging with slog LESSON 📋 slog Workshop WORKSHOP 📦 Go Modules & Packages LESSON 📦 Modules & Packages Workshop WORKSHOP 🚩 CLI Flags & Env Vars LESSON 🚩 CLI Flags Workshop WORKSHOP 🗄️ database/sql LESSON 🗄️ database/sql Workshop WORKSHOP 🗄️ Task Store Lab LAB 🛑 Graceful Shutdown LESSON 🛑 Graceful Shutdown Workshop WORKSHOP 🧩 Struct Embedding LESSON 🧩 Embedding Workshop WORKSHOP 🔍 Type Assertions & Type Switches LESSON 🔍 Type Assertions Workshop WORKSHOP 🔗 HTTP Middleware LESSON 🔗 HTTP Middleware Workshop WORKSHOP 🔗 Middleware Chain Lab LAB 📡 HTTP Client LESSON 📡 HTTP Client Workshop WORKSHOP ⏱️ Benchmarking LESSON ⏱️ Benchmarking Workshop WORKSHOP ⚛️ sync/atomic LESSON ⚛️ sync/atomic Workshop WORKSHOP 🔄 strconv — String Conversions LESSON 🔄 strconv Workshop WORKSHOP 🔬 Profiling with pprof LESSON 🔬 Profiling Workshop WORKSHOP 🔢 Sorting with the sort Package LESSON 🔢 sort Workshop WORKSHOP 🔎 Regular Expressions LESSON 🔎 regexp Workshop WORKSHOP 🏁 The Race Detector LESSON 🏁 Race Detector Workshop WORKSHOP 🎁 Error Wrapping & Sentinel Errors LESSON 🎁 Error Wrapping Workshop WORKSHOP ⚙️ Running Subprocesses with os/exec LESSON ⚙️ os/exec Workshop WORKSHOP
☰ ☰ 🔒 Closures Workshop WORKSHOP ~22 min
← Prev Mark Complete ✓ 🔍 🌙
Step 1
Write `makeCounter() func() int` that returns a closure. Each call to the returned function should increment an internal counter by 1 and return the new value. The counter starts at 0.
▶ Run & Check Ctrl+Enter to run ☁ Playground
💡 Show Hint