Golang has a number of built-in data types that cover the various types of values that a program can represent. Here are some of the main data types in Golang briefly (for details on each data type, see the links or buttons that we include for each data type):
Integer
- int and uint (depending on whether the integer is signed or unsigned).
- Specific-sized data types, such as int8, int16, int32, int64, uint8, uint16, uint32, and uint64.
Float
float32 and float64 for floating-point numbers.
Boolean
bool for true or false values
String
string for text or character representation.
Rune
rune to represent a single Unicode character.
Complex
complex64 and complex128 for complex numbers.
Array
array for a collection of elements with a fixed size..
Slice
slice for a collection of elements with a dynamic size.
Map
map untuk koleksi pasangan kunci-nilai.
Struct
struct untuk membuat tipe data baru yang dapat menyimpan berbagai jenis data dengan nama-nama tertentu.
Pointer
pointer untuk mereferensikan alamat memori dari suatu nilai.
Function
function untuk merepresentasikan fungsi.
Interface
interface untuk mendefinisikan perilaku suatu objek.
Channel
channel untuk komunikasi antar goroutine.
Tipe data di Golang bersifat statis, artinya tipe data variabel harus dideklarasikan sebelum digunakan. Golang memiliki sistem tipe data yang kuat dan eksplisit, membantu dalam penanganan kesalahan dan meningkatkan keamanan kode.