
Data Type คือชนิดของข้อมูลที่ใช้ในโปรแกรม มีความสำคัญอย่างยิ่งที่ต้องระบุ Data Type ให้กับข้อมูลนั้นเพื่อประโยชน์ในการประมวลผลของโปรแกรม
Data type in Go
ประเภทข้อมูลของภาษา Go แบ่งออกเป็น 4 หมวดใหญ่คือ
- ฺBasic Data Type
- Aggregate Data Type
- Reference Type
- Interface Type
Basic data type
ประกอบด้วยประเภทข้อมูลย่อยคือ
- bool
- string
- int, int8, int16, int32, int64, uint, unit8, unit16, unit32, unit64
- byte
- rune
- float32, float64
- complex64, complex128
Aggregate data type
ประเภทข้อมูลในหมวดนี้ประกอบด้วย
- Array
- Structs
Reference data type
ประกอบด้วย
- Pointer
- Slices
- Maps
- Function
- Channels
Interface
Data type ชนิดนี้มีขึ้นให้ programmer สามารถนิยามชนิดของข้อมูลขึ้นมาใช้งานได้เพื่อให้บรรลุวัตถุประสงค์ของการเขียนโปรแกรม
สรุป
เมือทราบแล้วว่าประเภทข้อมูลใดบ้างที่สามารถใช้เขียนภาษา GO ได้ ในบทความต่อๆไปจะอธิบายถึงการใช้งานของประเภทข้อมูลต่างๆที่ใช้ในการเขียนโปรแกรม
แหล่งที่มาของข้อมูล
https://www.geeksforgeeks.org/data-types-in-go/
https://tour.golang.org/basics/11
https://www.alexedwards.net/blog/interfaces-explained
Leave a Reply