#go
85 notes carry this tag.
Express'dagi ikki endpoint'li API'ni Go'da 20 qatorda yozamiz: go mod, go run/go build, bitta binary, GOOS/GOARCH va FROM scratch'dagi cgo tuzogʻi.
We rewrite a two-endpoint Express API in 20 lines of Go: go mod, go run/go build, one binary, GOOS/GOARCH and the cgo trap in FROM scratch.
What a variable is, the difference between := and =, how x = x + 1 runs, and what a copy is: for people who have never written code.
Why Go const is not JS const, where an untyped constant gets its type, why time.Sleep(2) = 2 ns and how a status added mid-iota breaks the database.
In Go, = and passing to a function copy a struct: the range trap, &user and *User, the struct-in-map error, slices vs arrays.
Dastur, kompilyator va terminal nima, Salom, dunyo dasturining har bir qatori va xato xabarini oʻqish: hech qachon kod yozmaganlar uchun.
defer tartibi va argument vaqti, sikldagi defer tuzogʻi, panic'ni recover bilan xatoga aylantirish va recover ushlay olmaydigan fatal error'lar.
The order of defer and when its arguments are evaluated, the defer-in-a-loop trap, turning a panic into an error with recover, and fatal errors recover cannot catch.
Порядок defer и момент вычисления аргументов, ловушка defer в цикле, превращение panic в ошибку через recover и fatal error, которые recover не ловит.
Write a test, a table-driven test and subtests with go test, measure speed with b.Loop and -benchmem, and expose a benchmark that lied.
Wrapping errors with %w, finding them in the chain with errors.Is and errors.AsType, errors.Join, and the Go 1.25 nil check fix.
for sikli: sanagich, boshlanish · savol · qadam, 1 dan 5 gacha yigʻindi, cheksiz sikl va Ctrl+C, break: hech qachon kod yozmaganlar uchun.
The for loop: a counter, start · question · step, the sum of 1 to 5, an infinite loop and Ctrl+C, break: for people who have never written code.
Цикл for: счётчик, начало · вопрос · шаг, сумма от 1 до 5, бесконечный цикл и Ctrl+C, break: для тех, кто никогда не писал код.
A function returns several values and is a value itself; closures, variadic functions, and how to find the := shadowing bug.
Funksiya bir nechta qiymat qaytaradi va oʻzi ham qiymat; closure, variadic va := shadowing xatosini topish.
Type parameters and constraints, ~ and cmp.Ordered, generic methods in Go 1.27 and their limit, and three smells of needless generic code.
Type parameter va constraint, ~ va cmp.Ordered, Go 1.27 dagi generic metodlar va ularning cheklovi, ortiqcha generic kodning uchta hidi.
The four forms of for, why range gives a copy, switch and fallthrough, the break trap, labels, and the loop bug Go 1.22 fixed.
Go binary'sini bundle analyzer kabi ochamiz: runtime narxi, linker tree-shaking va paket init, FROM scratch'dagi vaqt zonasi xatosi va time/tzdata.
Go tilini sintaksisdan runtime ichigacha oʻrgatadigan trek: asoslar, idiomatik dizayn, concurrency, runtime internals, performance va Go manba kodini oʻqish.
go.mod'dagi go qatorining uchta vazifasi (til versiyasi, GODEBUG, minimal Go), MVS, go.sum, internal/ va tool direktivasi.
for'ning toʻrt shakli, range nusxa berishi, switch va fallthrough, break tuzogʻi, label va Go 1.22 tuzatgan sikl xatosi.
Переписываем API с двумя эндпоинтами с Express на Go в 20 строк: go mod, go run/go build, один бинарник, GOOS/GOARCH и ловушка cgo во FROM scratch.
Ikki sonni taqqoslash, true va false, if / else bilan chegirma va else if bilan baho dasturi: hech qachon kod yozmaganlar uchun.
Comparing two numbers, true and false, a discount with if / else and a grade with else if: for people who have never written code.
Сравнение двух чисел, true и false, скидка через if / else и оценка через else if: для тех, кто никогда не писал код.
Go interface'lari: yashirin bajarilish, (tur, qiymat) juftligi, type assertion, type switch va typed nil xatosi hamda uni topadigan staticcheck.
Go interfaces: implicit implementation, the (type, value) pair, type assertion, type switch, the typed nil bug and the staticcheck check that finds it.
Read a 1 GiB file in 2.5 MiB of memory: io.Reader, io.Writer, io.EOF, your own Writer, io.Copy and gzip as a stream.
1 GiB faylni 2.5 MiB xotirada oʻqish: io.Reader, io.Writer, io.EOF, oʻz Writer'imiz, io.Copy va gzip bilan oqim (stream).
Чтение файла в 1 GiB в 2.5 MiB памяти: io.Reader, io.Writer, io.EOF, свой Writer, io.Copy и gzip как поток (stream).
iter.Seq va yield bilan oʻz iterator'ingizni yozish, break'dan keyingi panic qoidasi, tezlik va slices, maps, cmp paketlaridan toʻgʻri foydalanish.
Write your own iterator with iter.Seq and yield, learn the panic rule after break, measure the speed, and use slices, maps and cmp correctly.
Go const nega JS const emas, untyped constant turini qayerdan oladi, nega time.Sleep(2) = 2 ns va iota roʻyxatiga qoʻshilgan holat bazani qanday buzadi.
Go'da string — baytlar: len, s[i] va == baytlar bilan ishlaydi. JS, Python va PHP bilan solishtiramiz, rune va oʻzbek apostrofi muammosini tuzatamiz.
A Go string is bytes: len, s[i] and == work on bytes. We compare with JS, Python and PHP, meet runes and fix the Uzbek apostrophe problem.
Строка в Go — это байты: len, s[i] и == работают с байтами. Сравниваем с JS, Python и PHP, разбираем руны и исправляем узбекские апострофы.
Map bilan ishlash (comma ok, delete, nil map), range tartibi nega tasodifiy va map'ga bir vaqtda yozish nega recover ushlamaydigan fatal error.
Работа с map (comma ok, delete, nil map), почему порядок range случайный и почему одновременная запись в map — fatal error, который recover не ловит.
Working with maps (comma ok, delete, nil map), why range order is random, and why concurrent map writes are a fatal error that recover cannot catch.
Methods and receivers, method sets and addressability: which call compiles, why String is not called, and which receiver to choose.
Metod va receiver, method set va addressability: qaysi chaqiruv kompilyatsiya boʻladi, String nega chaqirilmaydi va qaysi receiver tanlanadi.
In Go an error is not thrown but returned as a value: if err != nil, an error silently lost in a bare call, errcheck, and defer instead of finally.
What a value's type is, the difference between int, float64 and string, what + does with each, and how to read a mismatched types error.
Go'da = va funksiyaga uzatish struct'ni nusxalaydi: range tuzogʻi, &user va *User, map'dagi struct xatosi, slice va massiv farqi.
Oʻzgaruvchi nima, := va = farqi, x = x + 1 qanday bajarilishi va nusxa olish: hech qachon kod yozmaganlar uchun.
The three jobs of the go line in go.mod (language version, GODEBUG, minimum Go), MVS, go.sum, internal/ and the tool directive.
Pointer (& va *), stek va heap, -gcflags=-m bilan kompilyator qarorini oʻqish, inline taʼsiri va &s[0] + append tuzogʻi.
Pointers (& and *), stack and heap, reading compiler decisions with -gcflags=-m, the effect of inlining, and the &s[0] + append trap.
Slice ichida nima bor (pointer, len, cap), append qachon eski massivga yozadi, tuzoqni tuzatish va slice oʻsishini oʻzingiz oʻlchash.
What is inside a slice (pointer, len, cap), when append writes into the old array, how to fix the trap, and how to measure slice growth yourself.
Qiymatning turi nima, int, float64 va string farqi, + har birida nima qiladi va turlar mos emas xatosini qanday oʻqish.
Struct va composite literal, embedding, keyin padding va alignment: maydonlar tartibi struct oʻlchamini qanday oʻzgartiradi va bu qachon muhim.
Structs and composite literals, embedding, then padding and alignment: how field order changes a struct's size, and when it matters.
go test bilan test, jadval test va subtest yozish, b.Loop va -benchmem bilan tezlikni oʻlchash va yolgʻon gapirgan benchmark'ni fosh qilish.
Go'da xato throw qilinmaydi, u qaytariladigan qiymat: if err != nil, natijasiz chaqiruvda jim yoʻqolgan xato, errcheck va finally oʻrniga defer.
TS turlari oʻchadi, Go'niki runtime'gacha qoladi: \"2\" + 2 build xatosi, JSON'dagi \"2\", zero value, := va =, shadowing, range indeksi va string(65).
Bir xil +1: Python aniq, JS yaxlitlaydi, Go manfiy son beradi. int8 … int64, two's complement, overflow va konstanta nega rad etiladi.
The same +1: Python is exact, JS rounds, Go gives a negative number. int8 … int64, two's complement, overflow and why constants are rejected.
TS types are erased, Go keeps them until runtime: \"2\" + 2 won't build, \"2\" in JSON, zero values, := vs =, shadowing, the range index and string(65).
What a program, a compiler and a terminal are, every line of the Salom, dunyo program, and how to read an error: for people who never wrote code.
Open a Go binary like a bundle analyzer: the runtime's cost, linker tree-shaking and package init, the FROM scratch time-zone bug and time/tzdata.
Xatoni %w bilan oʻrash, errors.Is va errors.AsType bilan zanjirdan topish, errors.Join, hamda Go 1.25 dagi nil tekshiruvi tuzatishi.
В Go ошибку не бросают, а возвращают как значение: if err != nil, ошибка, молча потерянная в вызове без результата, errcheck и defer вместо finally.
Четыре формы for, почему range даёт копию, switch и fallthrough, ловушка с break, метки и ошибка цикла, исправленная в Go 1.22.
Параметры типа и ограничения, ~ и cmp.Ordered, generic-методы Go 1.27 и их ограничение, три признака лишнего generic-кода.
Открываем Go-бинарник как bundle analyzer: цена runtime, tree-shaking в linker и init пакетов, ошибка часового пояса во FROM scratch и time/tzdata.
Интерфейсы Go: неявная реализация, пара (тип, значение), type assertion, type switch, ошибка typed nil и staticcheck, который её находит.
Свой итератор на iter.Seq и yield, правило panic после break, скорость и правильная работа с пакетами slices, maps и cmp.
Почему const в Go — не const из JS, откуда нетипизированная константа берёт тип, почему time.Sleep(2) = 2 нс и как статус в середине iota ломает базу.
В Go = и передача в функцию копируют struct: ловушка range, &user и *User, ошибка со struct в map, разница слайса и массива.
Метод и receiver, method set и адресуемость: какой вызов компилируется, почему String не вызывается и какой receiver выбрать.
Пишем тест, табличный тест и подтесты с go test, измеряем скорость с b.Loop и -benchmem и разоблачаем бенчмарк, который лгал.
Три задачи строки go в go.mod (версия языка, GODEBUG, минимальная версия Go), MVS, go.sum, internal/ и директива tool.
Обёртывание ошибок через %w, поиск в цепочке через errors.Is и errors.AsType, errors.Join и исправление nil-проверки в Go 1.25.
Что такое переменная, чем := отличается от =, как выполняется x = x + 1 и что такое копия: для тех, кто никогда не писал код.
Что внутри слайса (указатель, len, cap), когда append пишет в старый массив, как обойти ловушку и как самому измерить рост слайса.
Структура и составной литерал, встраивание (embedding), затем padding и выравнивание: как порядок полей меняет размер структуры и когда это важно.
Типы TS стираются, а в Go доживают до рантайма: \"2\" + 2 не собирается, \"2\" в JSON, zero value, := и =, затенение, индекс в range и string(65).
Один и тот же +1: Python точен, JS округляет, Go даёт отрицательное число. int8 … int64, дополнительный код, переполнение и константы.
Указатели (& и *), стек и куча, как читать решения компилятора через -gcflags=-m, влияние встраивания и ловушка &s[0] + append.
Функция возвращает несколько значений и сама является значением; замыкания, вариативные функции и поиск ошибки затенения через :=.
Что такое тип значения, чем отличаются int, float64 и string, что делает + с каждым из них и как читать ошибку mismatched types.
Что такое программа, компилятор и терминал, каждая строка программы Salom, dunyo и как читать ошибку: для тех, кто никогда не писал код.