{"id":460,"date":"2020-11-23T13:00:25","date_gmt":"2020-11-23T13:00:25","guid":{"rendered":"https:\/\/wordpress-660014-2156598.cloudwaysapps.com\/?p=460"},"modified":"2020-11-23T13:00:25","modified_gmt":"2020-11-23T13:00:25","slug":"get-to-know-the-go-or-golang-programming-language","status":"publish","type":"post","link":"https:\/\/matob.web.id\/news\/get-to-know-the-go-or-golang-programming-language\/","title":{"rendered":"Get to know the Go or Golang programming language"},"content":{"rendered":"<p>now we will learn the Go or Golang programming language.\u00a0<a href=\"https:\/\/matob.web.id\/news\/get-to-know-the-go-or-golang-programming-language\/\">What is Golang<\/a>?<\/p>\n<p>Go or Go Language, commonly abbreviated as Golang, is a programming language created and developed by the Google team.\u00a0This language was created by the google development team in 2007 and released to the public in 2009. Making golang is based on the C and C ++ languages.\u00a0This is what causes Golang and C to have a fairly similar syntax.\u00a0Unlike most new programming languages, Golang does not adopt Object Oriented or Generic programming.<\/p>\n<p>This language was originally created only for Google&#8217;s internal company, but in 2009 Golang was finally released to the public in an open-source manner which means that the code is open, can be written, modified, and redistributed.<\/p>\n<p>One of the famous Golang developer members is (Ken Thompson), a computer scientist who is also known as the developer of the Unix operating system.\u00a0The other members of the team are Robert Griesemer and Rob Pike.<\/p>\n<p>Golang is one of top 12 <a href=\"https:\/\/matob.web.id\/news\/12-of-the-most-popular-programming-languages\/\">the most popular programming language in the world<\/a>.<\/p>\n<h1>What can be made with Golang?<\/h1>\n<p>Golang can be used as a\u00a0beck end\u00a0language\u00a0for any program, be it website, mobile, and others.\u00a0This language is usually used to create RestAPI, due to its friendlier syntax and efficiency that is not inferior to the C language. As we all know efficiency is one of the most important things in choosing a programming language.\u00a0In the world of programming efficiency is a process in which few resources are used to achieve the expected results.<\/p>\n<p>Here are some applications made using golang:<\/p>\n<ul>\n<li>Monzo &#8211; An online banking application based in the United Kingdom.<\/li>\n<li>Allegro &#8211; Online Shop Application in Poland<\/li>\n<li>SoundCloud &#8211; Online sound distribution application that enables collaboration, promotion and distribution of sound recordings.<\/li>\n<li>Bado &#8211; Multi-language bureau based social networking service.<\/li>\n<li>Uber &#8211; Transportation Service Application from San Francisco (Once operated in Indonesia before finally Uber which operates in Southeast Asia in the acquisition of Grab).<\/li>\n<\/ul>\n<h1>Advantages of Golang<\/h1>\n<p>Just like other programming languages, Golang certainly has advantages over other programming languages.\u00a0Here are some of the advantages possessed by Golang:<\/p>\n<ul>\n<li><b>Easy to learn<\/b>\u00a0&#8211; Golang&#8217;s syntax is smaller which makes it easier to learn.<\/li>\n<li><b>Have concurrency<\/b>\u00a0&#8211; Concurency is the ability to split into smaller parts that can function independently.<\/li>\n<li><b>Have a garbage collector<\/b>\u00a0&#8211; The garbage collector is a tool for managing memory allocation.<\/li>\n<li><b>Faster<\/b>\u00a0&#8211; Golang is a fast language because it is compiled into machine code, in contrast to most other programming languages \u200b\u200bthat work with virtual runtime.<\/li>\n<li><b>Complementing the deficiencies of the previous language<\/b>\u00a0&#8211; Every new programming language comes with the aim of correcting the deficiencies of the previous language\u00a0Some of the shortcomings that can be overcome by groups such as lack of multicore support, lack of parallel computing support, complex type systems, and complicated memory management.<\/li>\n<\/ul>\n<h1>Golang Writing Rules<\/h1>\n<p>Each programming language has a different structure and writing rules.\u00a0Here are some writing rules and the use of certain functions in golang.<\/p>\n<h2>Method main<\/h2>\n<pre><code class=\"hljs java\">\n<span class=\"hljs-keyword\">package<\/span> main\n\n<span class=\"hljs-keyword\">import<\/span> <span class=\"hljs-string\">\"fmt\"<\/span>\n\n<span class=\"hljs-function\">func <span class=\"hljs-title\">main<\/span><span class=\"hljs-params\">()<\/span><\/span>{\n\t<span class=\"hljs-comment\">\/\/ kode disini<\/span>\n}\n<\/code><\/pre>\n<h2>Import package in Golang<\/h2>\n<p>Packages are used to use certain functions.\u00a0For example, the code below shows\u00a0<b>import &#8220;fmt&#8221; is<\/b>\u00a0used so that the program can use the\u00a0<b>fmt<\/b>\u00a0package\u00a0.<\/p>\n<pre><code class=\"hljs java\">\n<span class=\"hljs-keyword\">package<\/span> main\n\n<span class=\"hljs-keyword\">import<\/span> <span class=\"hljs-string\">\"fmt\"<\/span> <span class=\"hljs-comment\">\/\/ kode import<\/span>\n\n<span class=\"hljs-function\">func <span class=\"hljs-title\">main<\/span><span class=\"hljs-params\">()<\/span><\/span>{\n\t<span class=\"hljs-comment\">\/\/ content main<\/span>\n}\n<\/code><\/pre>\n<h2>Display writing<\/h2>\n<pre><code class=\"hljs java\">\n<span class=\"hljs-keyword\">package<\/span> main\n\n<span class=\"hljs-keyword\">import<\/span> <span class=\"hljs-string\">\"fmt\"<\/span>\n\n<span class=\"hljs-function\">func <span class=\"hljs-title\">main<\/span><span class=\"hljs-params\">()<\/span><\/span>{\n\tfmt.Println(<span class=\"hljs-string\">\"Halo dunia!\"<\/span>)\n}\n<\/code><\/pre>\n<p>To display the text in the golang program, the code\u00a0<b>fmt.Println (&#8220;Posts here&#8221;) is used<\/b>\u00a0, where previously we had to import the\u00a0<b>fmt<\/b>\u00a0package in\u00a0order to use\u00a0<b>Pintln (&#8220;&#8221;)<\/b>\u00a0.<\/p>\n<h2>Data Types and Variables<\/h2>\n<p>Broadly speaking, in Golang there are three types of data types, namely number, string, and boolean.\u00a0Number data types are data types that contain numbers which are divided into two, namely integers (whole numbers) and floating point (decimal).\u00a0The integer itself is further divided into:<\/p>\n<ul>\n<li>uint &#8211; a number data type whose content cannot be negative<\/li>\n<li>int &#8211; can be positive or negative numbers<\/li>\n<\/ul>\n<p>Apart from the two types of Integers above there are still\u00a0<b>bytes<\/b>\u00a0but this type of integer is rarely used.\u00a0To understand more about data types, the following is an example of a program that combines variables with data types.<\/p>\n<pre><code class=\"hljs css\">\n<span class=\"hljs-selector-tag\">package<\/span> <span class=\"hljs-selector-tag\">main<\/span>\n \n<span class=\"hljs-selector-tag\">import<\/span> \"<span class=\"hljs-selector-tag\">fmt<\/span>\"\n \n<span class=\"hljs-selector-tag\">func<\/span> <span class=\"hljs-selector-tag\">main<\/span>() {\n    <span class=\"hljs-attribute\">a <\/span>:= <span class=\"hljs-string\">\"Codingrakitan.blogspot.com\"<\/span> \n\u00a0\u00a0 \u00a0b := <span class=\"hljs-number\">7<\/span> \n\u00a0\u00a0 \u00a0c := true \n\u00a0\u00a0 \u00a0fmt.<span class=\"hljs-built_in\">Println<\/span>(<span class=\"hljs-string\">\"a = \"<\/span>, a)\n    fmt.<span class=\"hljs-built_in\">Println<\/span>(<span class=\"hljs-string\">\"b = \"<\/span>, b)\n    fmt.<span class=\"hljs-built_in\">Println<\/span>(<span class=\"hljs-string\">\"c = \"<\/span>, c)\n}\n<\/code><\/pre>\n<p>The code above will display the program as shown:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-461\" src=\"https:\/\/matob.web.id\/news\/wp-content\/uploads\/sites\/4\/2020\/11\/1.jpg\" alt=\"\" width=\"320\" height=\"146\" title=\"\" srcset=\"https:\/\/matob.web.id\/news\/wp-content\/uploads\/sites\/4\/2020\/11\/1.jpg 320w, https:\/\/matob.web.id\/news\/wp-content\/uploads\/sites\/4\/2020\/11\/1-300x137.jpg 300w\" sizes=\"auto, (max-width: 320px) 100vw, 320px\" \/><\/p>\n<h2>Kondisi if else<\/h2>\n<pre><code class=\"hljs java\">\n<span class=\"hljs-keyword\">package<\/span> main\n\n<span class=\"hljs-keyword\">import<\/span> <span class=\"hljs-string\">\"fmt\"<\/span>\n\n<span class=\"hljs-function\">func <span class=\"hljs-title\">main<\/span><span class=\"hljs-params\">()<\/span><\/span>{\n\ta := <span class=\"hljs-number\">10<\/span>\n\t\n\t<span class=\"hljs-keyword\">if<\/span> a &gt; <span class=\"hljs-number\">10<\/span> {\n\t\tfmt.Println(<span class=\"hljs-string\">\"Nilai a lebih besar dari 10\"<\/span>)\n\t}<span class=\"hljs-keyword\">else<\/span>{\n\t\tfmt.Println(<span class=\"hljs-string\">\"Nilai a tidak lebih besar dari 10\"<\/span>)\n\t}\n\n}\n<\/code><\/pre>\n<p>The code above shows a condition where if\u00a0<b>a&gt; 10<\/b>\u00a0then displays the words\u00a0<b>Value a is greater than 10,<\/b>\u00a0if not or otherwise, then display the words\u00a0<b>Value a not greater than 10<\/b>\u00a0.<\/p>\n<h2>The For loop<\/h2>\n<p>Here is an example program using the for loop system:<\/p>\n<pre><code class=\"hljs java\">\n<span class=\"hljs-keyword\">package<\/span> main\n\n<span class=\"hljs-keyword\">import<\/span> <span class=\"hljs-string\">\"fmt\"<\/span>\n\n<span class=\"hljs-function\">func <span class=\"hljs-title\">main<\/span><span class=\"hljs-params\">()<\/span><\/span>{\n\t<span class=\"hljs-keyword\">for<\/span> i := <span class=\"hljs-number\">0<\/span>; i &lt; <span class=\"hljs-number\">5<\/span>; i++ {\n    fmt.Println(<span class=\"hljs-string\">\"Nilai = \"<\/span>, i)\n}\n<\/code><\/pre>\n<p>The code above will display the value of writing five times with the value of i changing from 0 to 4. Why it starts from 0 because the variable i is initially formulated as\u00a0<b>i: = 0<\/b>\u00a0, then why only\u00a0goes\u00a0to 4 because\u00a0<b>i &lt;5<\/b>\u00a0means i is less than 5.<\/p>\n<h2>Write a comment<\/h2>\n<p>Comments are very useful for marking as well as providing information on a certain section.\u00a0The use of comments on the program is very useful if the application that has been created includes a lot of code, and helps programmers in doing teamwork.\u00a0There are two types of comments on golang, namely inline comments (one line) and multi line comments (many lines).\u00a0Inline comments use the\u00a0<b>\/\/<\/b>\u00a0sign\u00a0while multi-line comments use a line opening\u00a0<b>\/ *<\/b>\u00a0and a line closing\u00a0<b>* \/<\/b>\u00a0.\u00a0To better understand, see the example below:<\/p>\n<pre><code class=\"hljs java\">\n<span class=\"hljs-keyword\">package<\/span> main\n\n<span class=\"hljs-keyword\">import<\/span> <span class=\"hljs-string\">\"fmt\"<\/span>\n\n<span class=\"hljs-function\">func <span class=\"hljs-title\">main<\/span><span class=\"hljs-params\">()<\/span><\/span>{\n\t<span class=\"hljs-comment\">\/\/ ini adalah komentar inline<\/span>\n}\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre><code class=\"hljs java\">\n<span class=\"hljs-keyword\">package<\/span> main\n\n<span class=\"hljs-keyword\">import<\/span> <span class=\"hljs-string\">\"fmt\"<\/span>\n\n<span class=\"hljs-function\">func <span class=\"hljs-title\">main<\/span><span class=\"hljs-params\">()<\/span><\/span>{\n\t<span class=\"hljs-comment\">\/* ini adalah \n\tjenis\n\tkomentar multi line *\/<\/span>\n}\n<\/code><\/pre>\n<p>On the official site golang.org you can see that golang can be installed on Windows, MacOS, or Linux platforms.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>now we will learn the Go or Golang programming language.\u00a0What is Golang? Go or Go Language, commonly abbreviated as Golang, is a programming language created and developed by the Google team.\u00a0This language was created by the google development team in 2007 and released to the public in 2009. Making golang is based on the C [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":378,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[86,163],"class_list":["post-460","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software","tag-golang","tag-programming"],"_links":{"self":[{"href":"https:\/\/matob.web.id\/news\/wp-json\/wp\/v2\/posts\/460","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/matob.web.id\/news\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/matob.web.id\/news\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/matob.web.id\/news\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/matob.web.id\/news\/wp-json\/wp\/v2\/comments?post=460"}],"version-history":[{"count":0,"href":"https:\/\/matob.web.id\/news\/wp-json\/wp\/v2\/posts\/460\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/matob.web.id\/news\/wp-json\/wp\/v2\/media\/378"}],"wp:attachment":[{"href":"https:\/\/matob.web.id\/news\/wp-json\/wp\/v2\/media?parent=460"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/matob.web.id\/news\/wp-json\/wp\/v2\/categories?post=460"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/matob.web.id\/news\/wp-json\/wp\/v2\/tags?post=460"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}