آموزش برنامه نویسی Go – انواع داده در برنامه نویسی GO

آموزش برنامه نویسی Go – انواع داده در برنامه نویسی GO

آموزش برنامه نویسی Go – انواع داده در برنامه نویسی GO

در خدمت شما دوستان عزیر هستیم با آموزش برنامه نویسی Go – انواع داده در برنامه نویسی GO از وب سایت آموزشی سورس باران. در این جلسه با انواع داده در برنامه نویسی GO آشنا خواهید شد.

انواع داده در برنامه نویسی GO

در زبان Go نوع داده ها به سیستم وسیعی که برای مقدار دهی متغیر ها یا توابع به کار میرود مربوط میشود.نوع یک متغیر معلوم میکند که چقدر حافظه را اشغال شود والگوی آن چگونه کامپایل شود. انواع متغیر ها در این زبان عبارتند از:

متغیر Boolean Type در برنامه نویسی GO

اینها متغیرهای منطقی هستند که شامل دو مقدار a برای true و b برای false هست.

متغیر numeric type در برنامه نویسی GO

این متغیرهای ریاضی هستند که اعداد صحیح را با a و اعداد اعشاری را با b نشان میدهند.

متغیر String Types در برنامه نویسی GO

نوع داده رشته ای مجموعه ای از مقادیر رشته ای را نشان می دهند. که مجموعه از بابیت ها هستند و همچنین تغییر ناپذیر هستند.

 

توابع آرایه ای و ساختاری به انواع مجموعه ای مربوط هستندو نوع یک تابع مجموعه تمام توابع را با همان پارامتر های آن را تعیین میکند.ما انواع داده پایه را در بخش زیر میبینیم بقیه آنها در قسمت های بعد پرداخته خواهدشد.

 

نوع داده های صحیح در برنامه نویسی GO

نوع داده های صحیح از پیش تعریف شده عبارتند از

انواع داده های عددی دیگرهمچنین یک مجموعه از نوع داده عددی با سایز های مخصوص طراحی شده اند

 

In the Go programming language, data types refer to an extensive system used for declaring variables or functions of different types. The type of a variable determines how much space it occupies in storage and how the bit pattern stored is interpreted.

The types in Go can be classified as follows −

Sr.No. Types and Description
۱ Boolean types

They are boolean types and consists of the two predefined constants: (a) true (b) false

۲ Numeric types

They are again arithmetic types and they represents a) integer types or b) floating point values throughout the program.

۳ String types

A string type represents the set of string values. Its value is a sequence of bytes. Strings are immutable types that is once created, it is not possible to change the contents of a string. The predeclared string type is string.

۴ Derived types

They include (a) Pointer types, (b) Array types, (c) Structure types, (d) Union types and (e) Function types f) Slice types g) Interface types h) Map types i) Channel Types

Array types and structure types are collectively referred to as aggregate types. The type of a function specifies the set of all functions with the same parameter and result types. We will discuss the basic types in the following section, whereas other types will be covered in the upcoming chapters.

Integer Types

The predefined architecture-independent integer types are −

Sr.No. Types and Description
۱ uint8

Unsigned 8-bit integers (0 to 255)

۲ uint16

Unsigned 16-bit integers (0 to 65535)

۳ uint32

Unsigned 32-bit integers (0 to 4294967295)

۴ uint64

Unsigned 64-bit integers (0 to 18446744073709551615)

۵ int8

Signed 8-bit integers (-128 to 127)

۶ int16

Signed 16-bit integers (-32768 to 32767)

۷ int32

Signed 32-bit integers (-2147483648 to 2147483647)

۸ int64

Signed 64-bit integers (-9223372036854775808 to 9223372036854775807)

Floating Types

The predefined architecture-independent float types are −

Sr.No. Types and Description
۱ float32

IEEE-754 32-bit floating-point numbers

۲ float64

IEEE-754 64-bit floating-point numbers

۳ complex64

Complex numbers with float32 real and imaginary parts

۴ complex128

Complex numbers with float64 real and imaginary parts

The value of an n-bit integer is n bits and is represented using two’s complement arithmetic operations.

Other Numeric Types

There is also a set of numeric types with implementation-specific sizes −

Sr.No. Types and Description
۱ byte

same as uint8

۲ rune

same as int32

۳ uint

۳۲ or 64 bits

۴ int

same size as uint

۵ uintptr

an unsigned integer to store the uninterpreted bits of a pointer value

The post آموزش برنامه نویسی Go – انواع داده در برنامه نویسی GO appeared first on آموزش برنامه نویسی.

درباره نویسنده: administrator

ممکن است دوست داشته باشید

دیدگاهتان را بنویسید

نشانی ایمیل شما منتشر نخواهد شد. بخش‌های موردنیاز علامت‌گذاری شده‌اند *