{"id":60,"date":"2022-08-23T21:59:33","date_gmt":"2022-08-23T21:59:33","guid":{"rendered":"https:\/\/ideaes.xhere.eu.org\/?p=60"},"modified":"2022-08-23T21:59:33","modified_gmt":"2022-08-23T21:59:33","slug":"go-day2","status":"publish","type":"post","link":"https:\/\/ideaes.xhere.eu.org\/?p=60","title":{"rendered":"Go Day2"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">Boolean type<\/h3>\n\n\n\n<p>In Go a boolean is a type on its own and not an alias made from another type like an integer 0 or -1<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><br>Numeric types<\/h3>\n\n\n\n<p>Integers<\/p>\n\n\n\n<p>     Signed int type has varying size, but min 32 bits 8 bit (int8) through 64 bit (int64)<\/p>\n\n\n\n<p>     Unsigned integers 8 bit(byte and uint8) through 32 bit(uint32)<\/p>\n\n\n\n<p>     Arithmetic Addition, subtraction, multiplication, divider, reminder<\/p>\n\n\n\n<p>     Bitwise operations And, or, xor, and not<\/p>\n\n\n\n<p>     Zero value is 0<\/p>\n\n\n\n<p>    Can&#8217;t mix types in the same family (uint16+uint32=error)<\/p>\n\n\n\n<p>Floating point<\/p>\n\n\n\n<p>  Zero value is 0<\/p>\n\n\n\n<p>  32 and 64 bit versions<\/p>\n\n\n\n<p>    Literal styles<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Decimal (3.14)<\/li><li>Exponential (13e18 or 2E10)<\/li><li>Mixed (13.7e12)<\/li><\/ul>\n\n\n\n<p>   Arithmetic operations<\/p>\n\n\n\n<p>       Addition, subtraction, multiplication and division<\/p>\n\n\n\n<p>Complex numbers<\/p>\n\n\n\n<p>     Zero value is (0+0i)<\/p>\n\n\n\n<p>     64 and 128 bit versions<\/p>\n\n\n\n<p>     Built-in functions<\/p>\n\n\n\n<p>         complex &#8211; make complex number from two floats<\/p>\n\n\n\n<p>         real &#8211; get real part as float imag &#8211; get imaginary part as float<\/p>\n\n\n\n<p>     Arithmetic operations Addition, substraction, multiplication and division<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><br>Text types<\/h3>\n\n\n\n<p> Strings<\/p>\n\n\n\n<p>       UTF-8 Immutable Can be concatenated with plus operator Can be converted to []byte<br>Rune<\/p>\n\n\n\n<p>       UTF-32 Alias for int32 Special methods normally required to process e.g. strings.Reader#ReadRune<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><br>Constants<\/h3>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<p><br>Naming convention<\/p>\n\n\n\n<p>Typed constants<\/p>\n\n\n\n<p>Untyped constants<\/p>\n\n\n\n<p>Enumerated constants<\/p>\n\n\n\n<p>Enumeration expressions<\/p>\n<\/div><\/div>\n\n\n\n<p><br>Constants can be any primitive type (int, boolean, float, string), arrays can not be constants because they are always variable<\/p>\n\n\n\n<p>Can be shadowed<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Arrays<\/h3>\n\n\n\n<p><\/p>\n\n\n\n<p> Collection of items with same type<\/p>\n\n\n\n<p> Fixed size<\/p>\n\n\n\n<p> Declaration styles<\/p>\n\n\n\n<p>     a := [3]int{1, 2, 3}<\/p>\n\n\n\n<p>     a := [&#8230;]int{1, 2, 3}<\/p>\n\n\n\n<p>     var a [3]int<\/p>\n\n\n\n<p><br>Access via zero-based index<\/p>\n\n\n\n<p>     a := [3]int {1, 3, 5} \/\/ a[1] == 3<\/p>\n\n\n\n<p>len function returns size of array<\/p>\n\n\n\n<p> Copies refer to different underlying data<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Slices<\/h3>\n\n\n\n<p>Backed by array<\/p>\n\n\n\n<p>Creation styles<\/p>\n\n\n\n<p>Slice existing array or slice<\/p>\n\n\n\n<p>Literal style<\/p>\n\n\n\n<p>Via make function<\/p>\n\n\n\n<p>    a := make([]int, 10) \/\/ create slice with capacity and length == 10<\/p>\n\n\n\n<p>    a := make([]int, 10, 100) \/\/ slice with length == 10 and capacity == 100<\/p>\n\n\n\n<p>len function returns length of slice<\/p>\n\n\n\n<p>cap function returns length of underlying array<\/p>\n\n\n\n<p>append functions to add elements to slice<\/p>\n\n\n\n<p>    May cause expensive copy operation if underlying array is too small<\/p>\n\n\n\n<p>Copies refer to same underlying array<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Boolean type In Go a boolean is a type on its own and not an alias made from another type like an integer 0 or -1 Numeric types Integers Signed int type has varying size, but min 32 bits 8 bit (int8) through 64 bit (int64) Unsigned integers 8 bit(byte and uint8) through 32 bit(uint32) &#8230;.&nbsp;&nbsp;<a class=\" default\" href=\"https:\/\/ideaes.xhere.eu.org\/?p=60\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"pagelayer_contact_templates":[],"_pagelayer_content":"","footnotes":""},"categories":[12],"tags":[],"class_list":["post-60","post","type-post","status-publish","format-standard","hentry","category-golang"],"_links":{"self":[{"href":"https:\/\/ideaes.xhere.eu.org\/index.php?rest_route=\/wp\/v2\/posts\/60","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ideaes.xhere.eu.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ideaes.xhere.eu.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ideaes.xhere.eu.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ideaes.xhere.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=60"}],"version-history":[{"count":5,"href":"https:\/\/ideaes.xhere.eu.org\/index.php?rest_route=\/wp\/v2\/posts\/60\/revisions"}],"predecessor-version":[{"id":65,"href":"https:\/\/ideaes.xhere.eu.org\/index.php?rest_route=\/wp\/v2\/posts\/60\/revisions\/65"}],"wp:attachment":[{"href":"https:\/\/ideaes.xhere.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=60"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ideaes.xhere.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=60"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ideaes.xhere.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=60"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}