Go
Learn Go by typing simple, idiomatic code.
Practice Go's deliberate simplicity by typing it: goroutines and channels, interfaces, structs, and the explicit if err != nil error handling that defines the language. Each snippet is idiomatic Go, and an AI tutor explains every line — how a channel synchronizes goroutines, why interfaces are satisfied implicitly — so concurrency clicks as your fingers learn the syntax.
Progress0 / 667 solved · 0/50 sections
best wpm
0
avg wpm
0
accuracy
0%
runs
0
level
1
rating
1000
Run Go on your machine
1. Install the toolchain
brew install go # or: sudo apt install golang2. Save your code as hello.go, then compile & run
go run hello.goprogress by section
1Fundamentals0/10start →
2Strings In Depth0/17start →
Concatenation and lengthCase and trimmingContains, HasPrefix, HasSuffixCount and RepeatSprintf builds a stringStrings are immutable; []byte is notFields splits on whitespaceIndexing gives a byteIndex finds an offsetReplace and ReplaceAllSlice by byte rangeSplit and Joinstrconv converts numbersstrings.Builderrange decodes UTF-8Runes are code pointsunicode/utf8
3Values & References0/15start →
Go passes by value& and *Maps are reference-likenew allocates a zero valueThe nil pointerPointers mutate the callerSlices are reference-likeStruct assignment copiesPointer to a structSwap via pointersArrays copy on passPointer receiver mutatesrange gives copiesReturn a local's addressValue receiver gets a copy
4Slices & Arrays0/16Unlock →
5Data structures0/10Unlock →
6Iterators0/15Unlock →
7Traits0/21Unlock →
The empty interface (any)Define an interfaceType assertionComma-ok assertionThe error interfaceComparable struct keysOne interface, many typesSmall interfacessort.Slicefmt.StringerAccept interfaces, return structsStatic satisfaction checkShared behavior via embeddingInterface embeddingsort.InterfaceInterface type switchInterface as a constraintiter.Seq iteratorjson.MarshalerNil interface pitfallPointer receiver method set
8Generics0/15Unlock →
9Lifetimes0/20Unlock →
defer for cleanupNo manual lifetimesClosures capture by referencedefer a Closedefer runs LIFOReturn a pointer to a localBlock scope and shadowingClosures keep state alivedefer captures args earlyEscape analysisTwo pointers, one valueSlices share a backing arrayPer-iteration loop variablecontext.WithCancelcontext.WithTimeoutcontext carries a valuedefer and recoverBound a goroutine's lifetimedefer mutates a named returnselect on ctx.Done()
10Closures0/16Unlock →
11Pattern Matching0/15Unlock →
12Error Handling0/20Unlock →
Errors as return valueserrors.Newfmt.Errorfpanic for invariantsdefer for cleanupCompute a fallbackComma-ok to errorKeep only successesAdd context to an errorCustom error typeStop at the first bad itemerrors.Is through a chainerrors.JoinReturn on first failureSentinel errorserrors.UnwrapWrap with %werrors.AsErrors with a kindrecover from a panic
13Option & Result0/20Unlock →
Comma-ok map lookupA nil slice is usableThe (value, error) pairZero valuesComma-ok inside ifErrors are valuesReturn (index, found)Early return on !okValue or default helperMultiple return valuesNamed returnsGuard a nil pointerRead a nil mapFallback when absenterr == nil is the ok signalType assertion, comma-okChannel receive, comma-oknil terminates a chainOptional struct fieldPointer as optional
14Conversions0/15Unlock →
15Collection Conversions0/19Unlock →
Flatten nested slicesMap keys to a sliceMap values to a slicePairs to a mapSet membershipSet to sorted sliceslices.Contains and IndexSlice to a setSort then compactFrequency mapMap to sorted pairsmaps.CloneSlice to index mapIterate in key orderTwo slices to a mapDedup keeping orderGroup by a keyInvert a mapSet intersection
16Math0/14Unlock →
17Encoding0/22Unlock →
Bytes to StringString to bytesASCII checks and caseDigit character valueHex encodeBinary, octal, hex formattingRune to code pointBase64 decodeBase64 encodeBig-endian bytesList code pointsEscape a stringHex decodeLittle-endian bytesBytes vs runesParse a number in a baseURL query escapeURL query unescapeValidate UTF-8Caesar cipherROT13XOR cipher
18Random0/20Unlock →
Random integer below nRandom float in [0, 1)Coin flipPick a random elementWeighted true/falseRandom permutationRandom number in a rangeA seeded sourceShuffle a sliceRandom bytesRandom enum valuePassword generatorReproducible sequencesRandom alphanumeric stringDice histogramNormal distributionSample k without replacementSecure random bytesWeighted choiceUUID version 4
19Data I/O0/19Unlock →
Parse CSV into rowsTab-separated valuesBuild a CSV stringSelect one columnCSV into a number matrixSplit off the headerSerialize a struct to JSONWhitespace-separated matrixRead a data fileSerialize records to CSVSkip blanks and commentsPrint an aligned tableWrite CSV to a fileWrite a matrix as textAppend a rowStream lines with a ScannerParse JSON into a structParse key=value configDrop unparseable rows
20Linear Algebra0/21Unlock →
Matrix shapeScalar multiplyA matrix of zerosElementwise addArgmax of a vectorIdentity matrixOne-hot encodeTraceStack rows (vstack)ReLU and sigmoidApply a function elementwiseColumn meansColumn sumsCosine similarityFlat storage, 2D indexingMatrix times vectorTransposeMatrix multiplyMin-max normalize columnsSoftmaxStandardize columns (z-score)
21Text Processing0/16Unlock →
22Date & Time0/12Unlock →
23Memory0/12Unlock →
24Modules0/20Unlock →
Import a packageThe package clauseImport aliasExported constantEnum with iotaExported vs unexportedGrouped importsStandard-library tourPackage-level variableConstructor functionThe go.mod fileImport pathsThe init functionA small utility packageThe Stringer interfaceA struct with a methodBlank importPrivate field, public getterAn interfacePointer receiver
25Macros0/20Unlock →
Slice literalsGo has no macrosPrint to standard errorNo assert macroCount argumentsMap literalsA todo placeholderVariadic functionsBuild constraintsA dbg-style helperfmt verbs and flagsPassing a function as an argumentGenerics as compile-time abstractionThe go:generate directivereflect.TypeOfreflect.ValueOf over fieldsBuild text with strings.BuilderA generic variadic maxStruct field tagsCode generation with text/template
26Testing0/20Unlock →
A basic testt.Errorf reports a failureTesting string outputCovering both branchesTesting the comma-ok resultComparing slicesA testable examplet.Fatalf stops the testA test helper with t.HelperTesting a methodTesting an out-of-range panicSkipping a slow testSubtests with t.RunTesting an error caseTesting a returned errorComparing floatsChecking the panic valueTesting that code panicsTable-driven testsTesting unexported functions
27Algorithms0/10Unlock →
28Sorting Algorithms0/12Unlock →
29Expression Parsing0/6Unlock →
30Idioms0/9Unlock →
31OOP & Traits0/8Unlock →
32Trait Objects0/14Unlock →
Interface parameterA heterogeneous []anyA pipeline of funcsReturn an interfaceSlice of interface valuesType switchRecover the concrete typeInterface embedding anotherEmbed an interface in a structA function registryA shared interface valueCommand dispatch mapTyped nil vs nil interfaceProbe for an optional interface
33Design Patterns0/14Unlock →
35File I/O0/6Unlock →
36Filesystem0/18Unlock →
Does a path exist?Copy a fileCreate nested directoriesFiles vs directoriesBuild a pathList a directoryRename or moveChange the extensionFile metadataPath componentsRemove files and treesSorted listingWrite to a temp dirAbsolute pathFilter by extensionLast modified timeTotal size of a treeWalk the tree
37Networking0/16Unlock →
Classify an IP addressSplit host and portParse a URLRead a line from a streamA read deadlineBind an ephemeral portAn HTTP clientResolve a hostnameParse an HTTP requestRouting with ServeMuxDial a TCP serverReadFromUDP gives the senderUDP send and receiveA goroutine per connectionTCP echo over an ephemeral portA tiny HTTP server
38Concurrency0/7Unlock →
39Unsafe & FFI0/14Unlock →
40Commands0/14Unlock →
41Array0/10Unlock →
43String0/10Unlock →
45Interval0/5Unlock →
46Linked List0/6Unlock →
47Tree0/14Unlock →
Maximum Depth of Binary TreeInvert Binary TreeSame TreeLowest Common Ancestor of a BSTBinary Tree Level Order TraversalSubtree of Another TreeImplement Trie (Prefix Tree)Kth Smallest Element in a BSTValidate Binary Search TreeAdd and Search WordConstruct Binary Tree from Preorder and InorderBinary Tree Maximum Path SumSerialize and Deserialize Binary TreeWord Search II