{"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 class=\"wp-block-paragraph\">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 class=\"wp-block-paragraph\">Integers<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">     Signed int type has varying size, but min 32 bits 8 bit (int8) through 64 bit (int64)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">     Unsigned integers 8 bit(byte and uint8) through 32 bit(uint32)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">     Arithmetic Addition, subtraction, multiplication, divider, reminder<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">     Bitwise operations And, or, xor, and not<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">     Zero value is 0<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">    Can&#8217;t mix types in the same family (uint16+uint32=error)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Floating point<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">  Zero value is 0<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">  32 and 64 bit versions<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">    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 class=\"wp-block-paragraph\">   Arithmetic operations<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">       Addition, subtraction, multiplication and division<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Complex numbers<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">     Zero value is (0+0i)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">     64 and 128 bit versions<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">     Built-in functions<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">         complex &#8211; make complex number from two floats<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">         real &#8211; get real part as float imag &#8211; get imaginary part as float<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">     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 class=\"wp-block-paragraph\"> Strings<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">       UTF-8 Immutable Can be concatenated with plus operator Can be converted to []byte<br>Rune<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">       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 class=\"wp-block-paragraph\"><br>Naming convention<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Typed constants<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Untyped constants<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Enumerated constants<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Enumeration expressions<\/p>\n<\/div><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><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 class=\"wp-block-paragraph\">Can be shadowed<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Arrays<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"> Collection of items with same type<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"> Fixed size<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"> Declaration styles<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">     a := [3]int{1, 2, 3}<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">     a := [&#8230;]int{1, 2, 3}<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">     var a [3]int<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><br>Access via zero-based index<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">     a := [3]int {1, 3, 5} \/\/ a[1] == 3<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">len function returns size of array<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"> Copies refer to different underlying data<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Slices<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Backed by array<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Creation styles<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Slice existing array or slice<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Literal style<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Via make function<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">    a := make([]int, 10) \/\/ create slice with capacity and length == 10<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">    a := make([]int, 10, 100) \/\/ slice with length == 10 and capacity == 100<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">len function returns length of slice<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">cap function returns length of underlying array<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">append functions to add elements to slice<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">    May cause expensive copy operation if underlying array is too small<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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}]}}