Go Weekly Tutorial : Data Type

Data Type คือชนิดของข้อมูลที่ใช้ในโปรแกรม มีความสำคัญอย่างยิ่งที่ต้องระบุ Data Type ให้กับข้อมูลนั้นเพื่อประโยชน์ในการประมวลผลของโปรแกรม

Data type in Go

ประเภทข้อมูลของภาษา Go แบ่งออกเป็น 4 หมวดใหญ่คือ

  1. ฺBasic Data Type
  2. Aggregate Data Type
  3. Reference Type
  4. Interface Type

Basic data type

ประกอบด้วยประเภทข้อมูลย่อยคือ

  1. bool
  2. string
  3. int, int8, int16, int32, int64, uint, unit8, unit16, unit32, unit64
  4. byte
  5. rune
  6. float32, float64
  7. complex64, complex128

Aggregate data type

ประเภทข้อมูลในหมวดนี้ประกอบด้วย

  1. Array
  2. Structs

Reference data type

ประกอบด้วย

  1. Pointer
  2. Slices
  3. Maps
  4. Function
  5. 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

Be the first to comment

Leave a Reply

Your email address will not be published.


*