آموزش برنامه نویسی 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
1Boolean types

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

2Numeric types

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

3String 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.

4Derived 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
1uint8

Unsigned 8-bit integers (0 to 255)

2uint16

Unsigned 16-bit integers (0 to 65535)

3uint32

Unsigned 32-bit integers (0 to 4294967295)

4uint64

Unsigned 64-bit integers (0 to 18446744073709551615)

5int8

Signed 8-bit integers (-128 to 127)

6int16

Signed 16-bit integers (-32768 to 32767)

7int32

Signed 32-bit integers (-2147483648 to 2147483647)

8int64

Signed 64-bit integers (-9223372036854775808 to 9223372036854775807)

Floating Types

The predefined architecture-independent float types are −

Sr.No.Types and Description
1float32

IEEE-754 32-bit floating-point numbers

2float64

IEEE-754 64-bit floating-point numbers

3complex64

Complex numbers with float32 real and imaginary parts

4complex128

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
1byte

same as uint8

2rune

same as int32

3uint

32 or 64 bits

4int

same size as uint

5uintptr

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

 

لیست مطالب جلسه قبل برنامه نویسی Go

  1. آموزش برنامه نویسی Go – زبان برنامه نویسی گو چیست؟ آشنایی با زبان و محیط برنامه نویسی Go
  2. آموزش برنامه نویسی Go – ساختار برنامه نویسی GO
  3. آموزش برنامه نویسی Go – قواعد برنامه نویسی GO
5/5 - (1 امتیاز)

راستی! برای دریافت مطالب جدید در کانال تلگرام یا پیج اینستاگرام سورس باران عضو شوید.

پکیج آموزش صفر تا صد فتوشاپ به زبان فارسی – حرفه ای شوید

دسته بندی موضوعات

آخرین محصولات فروشگاه

مشاهده همه

نظرات

بازخوردهای خود را برای ما ارسال کنید

این سایت از اکیسمت برای کاهش هرزنامه استفاده می کند. بیاموزید که چگونه اطلاعات دیدگاه های شما پردازش می‌شوند.