ข้ามไปยังเนื้อหา

Glossary

หน้านี้คือข้อตกลงเรื่องคำศัพท์ของทั้ง course เราคง term ภาษาอังกฤษไว้ตามที่ developer ไทยใช้จริงในการทำงาน และอธิบายความหมายเป็นภาษาไทย เวลาอ่านบทเรียนแล้วเจอคำที่ไม่คุ้น ให้กลับมาดูที่นี่

EnglishThai Styleหมายเหตุ
Goroutinegoroutineunit of concurrent work ใน Go
Schedulerschedulerจัดสรร goroutine ลง OS thread
Runtimeruntimeระบบ runtime ของ Go
Stackstackmemory สำหรับ local variable และ function call
Heapheapmemory สำหรับค่าที่ escape ออกจาก stack — ตัดสินโดย escape analysis ไม่ใช่ “ค่าที่อายุยาว”
Garbage CollectorGarbage Collector / GCทำความสะอาด heap อัตโนมัติ
Escape AnalysisEscape Analysiscompiler ตัดสินว่าค่าอยู่ stack ได้หรือต้องไป heap
Context Switchcontext switchสลับระหว่าง goroutine
Preemptionpreemptionบังคับหยุด goroutine เพื่อให้ตัวอื่นทำงาน
EnglishThai Styleหมายเหตุ
Memory Allocationmemory allocationจองหน่วยความจำ
Memory Layoutmemory layoutรูปแบบการวางข้อมูลใน memory
Heap Allocationheap allocationจอง memory บน heap
Stack Allocationstack allocationจอง memory บน stack
Stack Growthstack growthstack ขยายขนาดแบบ dynamic
Pointerpointerตัวแปรที่เก็บ memory address
Work Stealingwork stealingscheduler ขโมยงานจาก P ตัวอื่น
EnglishThai Styleหมายเหตุ
Channelchannelท่อสื่อสารระหว่าง goroutine
Mutexmutexlock สำหรับ mutual exclusion
RWMutexRWMutexread/write mutex
Atomicatomicoperation ที่ goroutine อื่นเห็นเป็นหน่วยเดียว แบ่งครึ่งไม่ได้
WaitGroupWaitGroupรอ goroutine หลายตัวให้เสร็จ
Selectselectรอหลาย channel operation พร้อมกัน แล้วทำงานกับตัวที่พร้อมหนึ่งตัว
Deadlockdeadlockgoroutine รอกันเองไม่มีที่สิ้นสุด
Race Conditionrace conditiongoroutine หลายตัวเข้าถึง shared state พร้อมกันโดยไม่มีการ synchronize
Contextcontextค่าที่พก deadline, cancellation และ request-scoped value ข้าม function
Symbolความหมาย
GGoroutine — unit of work
MMachine — OS thread
PProcessor — scheduling context
EnglishThai Styleหมายเหตุ
Interfaceinterfaceชุดของ method signature ที่มีชื่อ
Satisfysatisfy / ตอบสนองtype มี method ครบตามที่ interface กำหนด จึงใช้แทนกันได้ โดยไม่ต้องประกาศ
Type Assertiontype assertionดึงหรือตรวจ concrete type ที่อยู่ใน interface value (ไม่ใช่ conversion)
Method Setmethod setชุด method ที่ผูกกับ type หนึ่ง ตัดสินว่า type นั้น satisfy interface ไหน
Embeddingembeddingใส่ type หนึ่งเป็น field ไม่มีชื่อในอีก type เพื่อ promote field และ method
Promotepromotefield หรือ method ของ embedded type ถูกเรียกผ่าน outer type ได้โดยตรง
Zero Valuezero valueค่าเริ่มต้นของทุก type เมื่อประกาศโดยไม่กำหนดค่า
Reflectionreflectionตรวจสอบ type ณ runtime
Assemblyassemblyภาษา assembly ที่ Go compiler ผลิต
Compilercompilerแปลง Go source เป็น binary
Linkerlinkerรวม object files เข้าด้วยกัน
EnglishThai Styleหมายเหตุ
Sentinel Errorsentinel errorerror ค่าคงที่ที่ประกาศไว้ให้ caller เทียบ เช่น io.EOF
Wrap / Unwrapwrap / unwrapห่อ error เดิมไว้ข้างในด้วย %w เพื่อเก็บ chain ไว้ให้ errors.Is/errors.As
Error Chainerror chainลำดับ error ที่ถูก wrap ซ้อนกัน
Panicpanicหยุดการทำงานปกติแล้วคลาย call stack
Recoverrecoverรับค่าจาก panic ใน deferred function เพื่อกลับสู่การทำงานปกติ
EnglishThai Styleหมายเหตุ
Type Parametertype parameterตัวแปร type ที่ประกาศในวงเล็บเหลี่ยมของ function หรือ type
Constraintconstraintinterface ที่จำกัดว่า type parameter เป็นอะไรได้บ้าง
Type Settype setเซตของ type ที่ constraint หนึ่งอนุญาต
Instantiateinstantiateระบุ type จริงให้ generic type หรือ function
Type Inferencetype inferencecompiler เดา type argument ให้จาก argument ที่ส่งเข้าไป
EnglishThai Styleหมายเหตุ
Iteratoriteratorfunction ที่ range วนได้ ตาม signature iter.Seq หรือ iter.Seq2
Yieldyieldcallback ที่ iterator เรียกเพื่อส่งค่าออกมาแต่ละรอบ
Push / Pullpush / pullpush iterator ส่งค่าให้ body; pull iterator (iter.Pull) ให้ caller ดึงค่าเอง
EnglishThai Styleหมายเหตุ
Marshal / Unmarshalmarshal / unmarshalแปลงค่า Go เป็น JSON และแปลงกลับ
Struct Tagstruct tagstring หลัง field ที่ package อย่าง encoding/json อ่านผ่าน reflection
Reader / WriterReader / Writerinterface หนึ่ง method ที่ทั้ง stdlib ใช้ร่วมกัน (io.Reader, io.Writer)
Bufferbufferที่พักข้อมูลชั่วคราวเพื่อลดจำนวน syscall
DurationDurationช่วงเวลาเป็น int64 นาโนวินาที มี type ของตัวเอง
Layoutlayoutstring ตัวอย่างเวลาที่ Go ใช้แทน format specifier เช่น 2006-01-02
EnglishThai Styleหมายเหตุ
Table-Driven Testtable-driven testเก็บ case เป็น slice ของ struct แล้ววนรันทีละ case
Subtestsubtesttest ย่อยที่สร้างด้วย t.Run ตั้งชื่อและรันแยกได้
Benchmarkbenchmarkวัดเวลาและ allocation ต่อ operation
Coveragecoverageสัดส่วน statement ที่ test แตะถึง
Race Detectorrace detectorเครื่องมือ runtime ที่รายงาน data race ที่เกิดขึ้นจริงระหว่างรัน
Static Analysisstatic analysisตรวจ code โดยไม่รัน เช่น go vet, staticcheck
Modulemoduleหน่วยของการ version และ distribute code มี go.mod หนึ่งไฟล์
Packagepackageหน่วยของการ compile และ scope ชื่อ เท่ากับหนึ่ง directory
Checksumchecksumค่า hash ใน go.sum ที่ยืนยันว่า dependency ไม่ถูกแก้
MVSMVSMinimal Version Selection — Go เลือก version ต่ำสุดที่ทุก requirement ยอมรับ
หลีกเลี่ยงใช้แทน
ดำเนินการจัดสรรหน่วยความจำallocate memory
กระบวนการเก็บกวาดหน่วยความจำGC
หน่วยประมวลผลแบบเบาgoroutine
กระบวนการเรียกใช้execute
ตัวชี้pointer
หน่วยความจำแบบกองซ้อนstack
หน่วยความจำแบบฮีปheap
ตัวจัดกำหนดการscheduler
ฟังก์ชันfunction
ประเภทข้อมูลtype
ผู้เรียกcaller
ยกระดับpromote
ฟอร์แมตformat
ตอบสนอง (นอกบริบท interface)satisfy